Exploring your Lab Setup
Notes
- Start a new sketch (File -> New Sketch)
- Copy and paste this file.
- Look at the board and the code
There is a blue LED on pin D5
- There is a green LED on pin D6
- There is a red LED on pin D7
- There is a push button connected to pin D4 and pin D2
- There is a photo-resistor connected to pin A6
- For now initialize the color pins
- Functions are just as you would expect
- Write a function that will blink an LED given
- Call this routine from
loop for each of the colors in turn.
- If we want, we can read from an digital or analog pin too
- You need to set the mode to be
INPUT
- then use
int digitalRead(pin_number); to get the value
- In the main loop, read the
SWITCH_PIN and print the status.
- This is problematic for several reasons
- button bounce
- missing the button press
- We will explore this further in the future.
- We can read from the analog pin
- You don't appear to need to set the pin mode for analog pins
-
int analogRead(pin_number);
- This reads the voltage on the pin
- 0 = no voltage
- 1025 = +5V
- In the main loop, read the value from the photo-resistor and print this.
- Cover, uncover, and shine your phone's bright light on the phototypesetter.