Arduino UNO와 Serial 통신하기.

여러가지 방법이 있지만, 가장 간단한 방법은 라즈베리파이의 USB 포트에 연결된 Arduino UNO와 직접 통신하는 방법이 가장 간단하다. Arduino UNO에 올라갈 스케치는 아래와 같다. void setup() { Serial.begin(9600); } void loop() { Serial.println("Hello World!"); delay(10000); } 1초 간격으로 "Hello World!"를 출력한다. 먼저 Arduino IDE를 실행하여 스케치를 Arduino UNO에 올린다. 라즈베리 파이에 올라갈 Code는 아래와 같다. /* Pi_Serial_test.cpp - SerialProtocol library - demo Copyright (c) 2014 NicoHood. All right reserved. Program to test serial communication Compile with: sudo gcc -o Pi_Serial_Test.o Pi_Serial_Test.cpp -lwiringPi -DRaspberryPi -pedantic -Wall sudo ./Pi_Serial_Test.o */ // just that the Arduino IDE doesnt compile these files. #ifdef RaspberryPi //include system librarys #include < stdio.h >...