Created
October 18, 2012 10:15
-
-
Save robertcasanova/3910869 to your computer and use it in GitHub Desktop.
Simple Communication: Raspberry -> Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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