Skip to content

Instantly share code, notes, and snippets.

@jdecaron
Created November 21, 2012 08:11
Show Gist options
  • Save jdecaron/4123750 to your computer and use it in GitHub Desktop.
Save jdecaron/4123750 to your computer and use it in GitHub Desktop.
udp.c
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