Skip to content

Instantly share code, notes, and snippets.

@robertcasanova
Created October 18, 2012 10:15
Show Gist options
  • Save robertcasanova/3910869 to your computer and use it in GitHub Desktop.
Save robertcasanova/3910869 to your computer and use it in GitHub Desktop.
Simple Communication: Raspberry -> Arduino
int output = 9;//embedded led output, maybe is 13
void setup() {
Serial.begin(9600);
pinMode(output, OUTPUT);
}
void loop() {
if(Serial.available() > 0) {
char command = toLowerCase(Serial.read());
if(command == 'a') {
digitalWrite(output,HIGH);
} else {
digitalWrite(output,LOW);
}
}
}
import serial
import time
arduino = serial.Serial('/dev/ttyAMA0')
while 1:
arduino.write('a')
time.sleep(1)
arduino.write('b')
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment