Back to Parent

Process

Setting up the circuit was straightforward. 

Writing the code for the initial exercise was fairly easy as the steps to write the code were given and I had to follow them. 

I struggled with writing the code for the next exercise (i.e. making the LED blink when the string input was "HIGH"). Within the for loop, to make the light blink, I was using the 'state' command instead of 'digitalWrite'.

i.e. 

 if(command == "HIGH"){

for( int i = 0; i <= 2; i++ )

{

state = HIGH;

delay( 1000 );

state = LOW;

delay( 1000 );

}

}else if(command == "LOW"){

state = LOW;

}else{

return -1;

}


This is wrong as the 'state' is an integer variable defined to convert and store the string command from the internet into an input that the particle device can understand. It is the 'digitalWrite' command that reads the integer input defined in 'state' and converts it into physical action in the circuit. 

Upon correcting my mistake, I was able to make the code work and the LED blink 3 times as per the requirement. 


Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0