Skip to content

Instantly share code, notes, and snippets.

@tabchas

tabchas/Receiver.pde

Created Jun 24, 2012
Embed
What would you like to do?
Wireless Target Identification - Arduino Receiver Code
void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, INPUT);
}
void loop()
{
if (digitalRead(6) == HIGH)
{
for(int i = 2; i <= 5; i++)
digitalWrite(i, LOW);
}
bool started = false;
bool ended = false;
bool transmitter = false;
int inData;
while(Serial.available() > 0)
{
char aChar = Serial.read();
if(aChar == '<')
{
started = true;
delay(15);
transmitter = false;
ended = false;
}
else if (aChar == 'T')
{
transmitter = true;
delay(15);
ended = false;
}
else if(aChar == '>')
{
ended = true;
break;
}
else
{
inData = aChar;
}
}
if(started && ended)
{
digitalWrite(inData - 47, HIGH);
started = false;
transmitter = false;
ended = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment