Introduction
The Raspberry Pi and Arduino are both popular boards, but each are better suited for different things. That said, why not combine the two?
In this guide, you will learn to connect an Arduino UNO to the Raspberry Pi and program it from an Arduino IDE within Raspbian. A Raspberry Pi 3 Model B+ is used here but the instructions are the same for any other board. We will build a circuit using a breadboard, and write a sketch on the Arduino IDE that will have LEDs lighting up.
Once you've mastered the basics, you are one step closer to working on more advanced projects that requires the use of both boards. These could include a smart home, or smart jukebox among many other projects.
Tools
-
sudo apt-get update && sudo apt-get upgrade sudo apt-get install arduino
-
-
-
-
/* * Blinks two LEDs when motion detected */ //variables int led1 = 5; int led2 = 6; int motion = 3; int wait = 500; //500ms = 1/2s void setup() { // put your setup code here, to run once: pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(motion,INPUT); } void loop() { // put your main code here, to run repeatedly: if (digitalRead(motion) == HIGH){ digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); delay(wait); digitalWrite(led1,LOW); digitalWrite(led2,LOW); delay(wait); } }
-