How to Program Arduino with Raspberry Pi

Today's example uses a Raspberry Pi 3 Model B+ to make the Arduino Uno blink the LED! The article will divide this tutorial into two parts: How to install the Arduino IDE and how to use the IDE on the Raspberry Pi. While it is possible to program the Arduino through Platformio, it is much simpler to do it this way for newbies.

Why use Raspberry Pi to program Arduino?

Usually, you'll want to do that because:

  1. You cannot use your PC normally.
  2. You join it for a learning experience.

But there are many other reasons. In fact, there's a good balance between having a standalone PC and using your Raspberry Pi!

Advantages

  1. Raspberry Pi uses less power than laptops.
  2. You can use the backup battery when there is no power.
  3. Save time when you already use it as an IoT terminal.

Defect

  1. Excessive heat generation can become a problem for Raspberry Pi if you don't have ventilation.

As such, the Raspberry Pi is good enough if you are working on a quick IoT project in a weekend. Just plug in your sensors, peripherals and Arduino, then enter the code to see if it works with the rest of the system.

But if you're still in the "have to figure out how to make this circuit work" stage, then use a suitable desktop. This will help reduce problems.

Things you will need

  1. Raspberry Pi with Raspberry Pi OS and USB port
  2. An Arduino
  3. One USB Type-A to USB Type-B connector
  4. Computer peripherals (monitor, keyboard and mouse)
  5. 250Ω resistor (optional)
  6. Small LED bulb (any color, optional)
  7. Breadboard and jumper wire (optional)

Install Arduino IDE

1. Open Chromium (or any browser) and go to https://www.arduino.cc/en/software.

2. Select 'Linux ARM 32 bits' .

How to Program Arduino with Raspberry Pi Picture 1

3. That will take you to a page that allows you to download and/or donate. You can click 'JUST DOWNLOAD' if you don't want to donate.

How to Program Arduino with Raspberry Pi Picture 2

4. This will open a new window. You can change the file name at the top and the download location on the left. Save button in the bottom right corner.

How to Program Arduino with Raspberry Pi Picture 3

5. You'll find it in the Downloads folder (or whatever folder you choose) when it's finished downloading. Double-click it to run the Archiver application. It may take a few minutes before it opens.

How to Program Arduino with Raspberry Pi Picture 4

6. Archiver will open your file, but it will take some time to finish reading. There is a circle on the bottom left flashing red and green. Wait for it to complete before doing anything else.

How to Program Arduino with Raspberry Pi Picture 5

7. Click 'Extract files'. It was the brown box icon, opened with an orange arrow pointing to the right.

How to Program Arduino with Raspberry Pi Picture 6

8. This will open a new window allowing you to choose some settings. You can change the value of the top text box to point to the 'Downloads' folder. Otherwise it will point to the 'tmp' directory by default. Click 'Extract' at the bottom right to complete the download.

How to Program Arduino with Raspberry Pi Picture 7

9. Close the Archiver, then go to the new folder and double click the 'install.sh' file.

How to Program Arduino with Raspberry Pi Picture 8

10. Click 'Execute' in the new window.

How to Program Arduino with Raspberry Pi Picture 9

11. Arduino IDE will be available at 'Pi logo > Electronics > Arduino IDE'.

How to Program Arduino with Raspberry Pi Picture 10

Programming with the Arduino IDE

1. Run the Arduino IDE from the Pi logo. You will find a green window where you can write your code.

How to Program Arduino with Raspberry Pi Picture 11

2. Copy and paste the following code:

void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED_BUILTIN, HIGH); delay(500); Serial.println("LED on"); digitalWrite(LED_BUILTIN, LOW); delay(500); Serial.println("LED off"); }

The code makes the LED turn on and outputs 'LED on' on the Serial Monitor for 0.5 seconds, then does the opposite, turns the LED off and outputs 'LED off' for the same amount of time.

3. To save, click File > Save or press Ctrl + S on your keyboard.

How to Program Arduino with Raspberry Pi Picture 12

4. Connect the cable. The Arduino Uno uses a USB Type-A to USB Type-B connector. The square edge plugs into the Arduino, while the rectangular edge plugs into the Raspberry Pi.

How to Program Arduino with Raspberry Pi Picture 13

5. To upload to the Arduino, click Sketch > Upload or press Ctrl + U on your keyboard.

How to Program Arduino with Raspberry Pi Picture 14

6. When uploading, the TX and RX LEDs will flash briefly, then run your program, which causes the L LED to turn on or off every 0.5 seconds.

How to Program Arduino with Raspberry Pi Picture 15

7. To make things a little easier to see, you could try connecting an LED bulb and a 250Ω resistor between D13 and GND. It's easier to do this on a breadboard, and be sure to disconnect the Arduino from the Raspberry Pi before doing anything with the pins.

8. If you do it right, the LED will light up and dim at regular 0.5 second intervals.

How to Program Arduino with Raspberry Pi Picture 16

9. To access Serial Monitor, click Tools > Serial Monitor or press Ctrl + Shift + M on your keyboard.

How to Program Arduino with Raspberry Pi Picture 17

Once done, you should be able to start doing things with the Raspberry Pi and Arduino.

5 ★ | 1 Vote

May be interested

  • How to install the Arduino IDE on CentOS 8How to install the Arduino IDE on CentOS 8
    before starting to create projects via arduino, users need to set up the ide for the programmable board. in this article, tipsmake will join you to learn how to install the latest arduino ide on centos 8.
  • How to add libraries in ArduinoHow to add libraries in Arduino
    ardunio libraries are frequently used programs available to help you learn about the limited number of ide sketches.
  • Download Arduino IDE 1.8.13: Great programming software for beginnersDownload Arduino IDE 1.8.13: Great programming software for beginners
    today, knowing how to code and code is a very useful skill to have. arduino ide is a piece of software that makes the programming world more accessible to beginners, with a simple interface and a community-oriented system.
  • Learn Pi Imager, How to Use Raspberry Pi ImagerLearn Pi Imager, How to Use Raspberry Pi Imager
    the raspberry pi foundation recently released a new application for recording sd cards for the raspberry pi. the new program, called raspberry pi imager, launches march 5, 2020.
  • How to use Raspberry Pi Imager to install Raspberry Pi OSHow to use Raspberry Pi Imager to install Raspberry Pi OS
    raspberry pi foundation recently released a new app for burning sd cards for raspberry pi. the new program, called raspberry pi imager, launched on march 5, 2020.
  • How to Use Ultrasonic Sensors in Arduino ProjectHow to Use Ultrasonic Sensors in Arduino Project
    arduino is an open-source microcontroller platform used in many applications. arduino boards are able to read inputs such as light on a sensor or the press of a button and turn it into an output. this wikihow teaches you how to create an...
  • How to connect two Arduino boards using I2CHow to connect two Arduino boards using I2C
    while a single arduino can accomplish many tasks, some projects may require the use of more than one board to handle different functions.
  • Difference between Elegoo and ArduinoDifference between Elegoo and Arduino
    if you've ever bought an arduino board, you may have seen elegoo boards with a cheaper starter kit. both are good options. so what is the difference between elegoo and arduino?
  • How to Set Up an Arduino UnoHow to Set Up an Arduino Uno
    so, you've just bought, or are considering buying, an arduino uno kit. your mind is probably full of questions about how you can get started right away maximizing your experience. nothing is stopping you from coding the next big thing on...
  • What is PWM in Arduino?What is PWM in Arduino?
    pwm is a widely used concept in physics, electronics and telecommunications. it is defined as a signal modulation form to obtain analog waveforms from digital inputs.