Friday, September 2, 2016

Iffy Statements2_CM

Making the LED 5 times per second when you press the button:



-I my answer is different from the solution: Inside the first if-statement, I added a for-loop from int i = 0 to < 5 that will do digitalWrite(ledPin, HIGH) and then delay(100) and then digitalWrite(ledPin, LOW) and then delay(100). This worked.

Do it ... or else:





-The LED is not supposed to do anything, you just need to look at the Serial Monitor and see how it detects when you press and release a button.

Commenting out the last line of code that sets the new state to the variable buttonState:

-Again, the LED is not supposed to turn on because that logic is not part of the program.
-When I commented out the line of code, buttonState is set to LOW at the time the program starts. The only time when val doesn't equal buttonState is when val = HIGH, therefore, I only saw the text when the button was pressed.

No comments:

Post a Comment