UDP Communications between a Raspberry Pi and an Arduino Using Lazarus / Free Pascal

In my prior post, I created a program for the arduino and a Free Pascal program for the PC that allowed them to communicate via UDP.

You will want to refer to that post as it contains most of the details on making the code work:


Once I had the program working between the Arduino and PC, I wanted to simply move the Pascal program from the PC to the Raspberry Pi (RPI), recompile, and have it work. Free Pascal is pretty good about this.

It nearly worked flawlessly. I only had to remove the windows multimedia extensions from the Pascal program. It then compiled fine (the RPI will not play a sound file like the Windows version does – not that it can’t, I just didn’t attempt to implement it).

What is really nice about this is I can get the program running on a PC first which is much easier (faster) to develop code on, then move it to the RPI for final debugging/testing. Well, assuming I’m not going to be making use of any hardware specific to the RPI.

If you have not done so already, install Lazarus on the Raspberry Pi:


The following file contains the arduino sketch (which is actually unchanged from the prior post) and the Pascal code that runs on the RPI.


This entry was posted in c-lazarus, c-rpi and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.