Hi there,
This is my first Arduino project. I am basically stuck in a DO WHILE LOOP within an IF ELSE IF statement. following is the coding for the Arduino IDE. This coding is used by visual studio 2015 in VB. it contains a toggle on/off button. upon pressing On the LED starts blinking but when I press off button then no response. I had find out that it is in a loop and there is no condition to break the loop further I think that in order to the system to read the ELSE IF statement, it should read the serial port first. BUT I don't know how to do this . I had been trying for so long but failed. Can anyone here help me with this Please!
void setup() {
pinMode(52, OUTPUT);
Serial.begin (9600);
}
void loop() {
int val;
if (Serial.available()){
delay (100);
while (Serial. available()>0 )
val=Serial.read ();
if (val == '1'){
do{
digitalWrite(52,HIGH);
delay(500);
digitalWrite(52,LOW);
delay(500);}
while(val=='1');
}
}
else if (val == '0') {digitalWrite(52,LOW);};
}