In this assignment you will again use digital sensors as input devices. In this example though, you will make a toggle switch.
Build your button circuit according to this schematic:
Add a second circuit with a resistor and an LED.
If needed, review the Arduino Reference page on digitalRead()
. You should also review Serial.println()
and the if()
else
conditionals as you will need to know how to print something and control an actuator based on the state of the button.
- For starter code, use your previous work with the button.
- Modify the code so your sketch does the following:
- The button switches on or off when the button is pressed and it stays on or off. This is a true toggle switch.
- The Serial Monitor displays a message every time the LED state changes so that it says "ON" or "OFF" to match the LED.
Use the video below as a reference.
Make sure your prototype behaves the same way as the one in the video. As in the previous assignment, make a new file here on GitHub containing your code.
https://www.youtube.com/watch?v=VdB4GWeVkvY
Make sure your prototype behaves the same way as the one in the video. As in the previous assignment, make a new file here on GitHub. Name it 3.6_Toggle_Switch.ino
and Commit it to the repository.
REMEMBER: THIS ASSIGNMENT REQUIRES BOTH A VIDEO OF YOUR PROTOTYPE SUBMITTED ON CANVAS AND CODE SUBMITTED ON GITHUB