SMAHO for Android
char val; // variable to receive data from the serial port
void setup()
{
pinMode(2, OUTPUT); //
Serial.begin(9600); // start serial communication at 9600bps
}
void loop()
{
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
if( val == 'A' ) // if 'A' was received
{
digitalWrite(2, HIGH); // turn ON the LED
}
if( val == 'a' ) // if 'a' was received
{
digitalWrite(2, LOW ); // turn OFF the LED
}
}
}
' end of code
so A/B/C/D/E/F/G/H to switch on and a/b/c/d/e/f/g/h to switch off.