Lesson Plan: Week 4
In Week 4 we will do the following (please, click on the Segment links below to access the course materials):
Segment 1:
Segment 2:
|
Homework 3: Three buttons control a green and a red LED.
Goal: Two buttons function as 'alarm conditions'. When both buttons are pressed together briefly (envision them as stand-ins for a pressure and a temperature sensor on a chemical reactor) then a red warning LED comes on and the green 'normal operations' LED goes off. The third button functions as an override for the alarm (envision the alarm goes on due to too high pressure and temperature at the same time, and then technicians come in to fix the issue and they want to turn the alarm off). So when the third button is pressed briefly the red LED goes off again and the green LED comes on to indicate that the alarm has been reset. Set-up: Buttons: Connect three buttons to digital pins of the Arduino. The buttons need to connect the pins to ground. Program the pins to be inputs with internal pull-up resistors using the pinMode() statement(this results in the pins being logic HIGH when the buttons are not pressed, and logic LOW when the buttons are pressed. LEDs: Connect a green and a red LED to two digital pins and program the pins to be outputs. Make sure you put 220k resistors in series with the LEDs to limit the current. Programming: Read out the buttons in the loop and use conditional statements and Boolean operators to evaluate the situation and control the LEDs. Helpful info: Intro to Programming videos about boolean operators and control structures, EEawesome videos about buttons and LEDs To get credit: The working set-up must be demonstrated to the instructors/TAs by end of the class on the due date. |