Pong - Arduino Source Code

int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // digital sensor
int inByte = 0; // incoming serial byte
int yLed = 3;
int gLed = 4;

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);

pinMode(yLed, OUTPUT); //
pinMode(gLed, OUTPUT); //

digitalWrite(yLed,LOW);
digitalWrite(gLed,LOW);
}

void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(0)/4;
// delay 10ms to let the ADC recover:
delay(10);
// read second analog input, divide by 4 to make the range 0-255:
secondSensor = analogRead(1)/4;
// read switch, multiply by 255
// so that you're sending 0 or 255:
thirdSensor = 255 * digitalRead(2);
// send sensor values:
Serial.print(firstSensor, BYTE);
Serial.print(secondSensor, BYTE);
Serial.print(thirdSensor, BYTE);

//digitalWrite(yLed, HIGH);
digitalWrite(gLed, HIGH);

if (Serial.read() == 66)
{
digitalWrite(yLed, HIGH);
delay(1000);
digitalWrite(yLed, LOW);
}
else if (Serial.read() == 67)
{
digitalWrite(gLed, HIGH);
delay(1000);
digitalWrite(gLed, LOW);
}
}
}