// by N M D Weerasinghe SLCOTM
String Incomming_msg = "";
void setup() {
// put your setup code here, to run once:
for (int i=2; i<6;i++)
{
pinMode(i, OUTPUT); // define PIN mode
digitalWrite(i, LOW); // Turn off LEDs
}
Serial.begin(9600);
Serial.println("Enter LED number to turn on , LED number x2 to turn off");
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0)
{
Incomming_msg = Serial.readString();
if(((Incomming_msg.toInt() >0) && (Incomming_msg.toInt()<5)))
{
digitalWrite(Incomming_msg.toInt() +1 ,1);
}
else if ((Incomming_msg.toInt()<9))
{
digitalWrite(Incomming_msg.toInt() -4 +1,0);
}
else Serial.println("Invalid number, Enter number 1 to 8 only");
}
}