Confirm that the pushbutton is working

1.    Wire a Boolean not block into the diagram:

serialMonitorBlinkLEDwithPushButton6

2.    Add an Extern Function block that calls the function Serial.println(“ON”).

3.    Encapsulate the Extern Function block in a compound block named Button On Test and activate Enabled Execution.

4.    Wire the Boolean not to the Button On Test block.

serialMonitorBlinkLEDwithPushButton7

5.    Generate code to run on the Arduino.

6.    Switch to the Arduino IDE and click on Tools > Serial Monitor.

7.    Press the pushbutton on the sensor.

The word ON is displayed in the serial monitor after each press, which confirms that the pushbutton is working correctly.

serialMonitorBlinkLEDwithPushButton9

8.    Close the serial monitor.