Created
November 21, 2012 08:11
-
-
Save jdecaron/4123750 to your computer and use it in GitHub Desktop.
udp.c
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 incomingByte = 0; | |
int nov = 12; | |
int numberOfBytes = 0; | |
int rta = 13; | |
void getLastByte(){ | |
for(int i = 0; i < numberOfBytes; i++){ | |
incomingByte = Serial.read(); | |
} | |
} | |
void setup() { | |
pinMode(nov, OUTPUT); | |
pinMode(rta, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
numberOfBytes = Serial.available(); | |
if(numberOfBytes > 0){ | |
getLastByte(); | |
if(incomingByte == 'x'){ | |
digitalWrite(rta, HIGH); | |
} | |
else if(incomingByte == 'y'){ | |
digitalWrite(nov, HIGH); | |
} | |
else if(incomingByte == 'z'){ | |
digitalWrite(nov, HIGH); | |
digitalWrite(rta, HIGH); | |
} | |
} | |
delay(3000); | |
digitalWrite(nov, LOW); | |
digitalWrite(rta, LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment