1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
-
Upload
mark-farmer -
Category
Documents
-
view
230 -
download
4
Transcript of 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
![Page 1: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/1.jpg)
1
- Remove LED from 13 and GND- Bring out your breadboard from HW#4
Arduino Overview:
![Page 2: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/2.jpg)
2
- Connect resistor row to GND on your Arduino
Arduino Overview:
![Page 3: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/3.jpg)
3
- Connect + lead of LED to Arduino pin 9
Arduino Overview:
![Page 4: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/4.jpg)
4
- Modify sketch to have LED blink on pin 9 through your breadboard
- Compile and Upload the code
- Do the LEDs blink?
- Switch pin number in sketch and hardware
- Tinker until all teams here
Arduino Overview:
![Page 5: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/5.jpg)
5
- Understanding what is happening on pin 9
- High ( = 1 ) and Low ( = 0 ) state
- Let’s use the Arduino Serial Monitor to verify
- Change delay to 3 seconds
Arduino Overview:
![Page 6: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/6.jpg)
6
- Modify the sketch to add the following variable
Arduino Overview:
![Page 7: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/7.jpg)
7
- Modify the sketch to add the following to the setup
Arduino Overview:
![Page 8: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/8.jpg)
8
- Modify the sketch to add the following to the loop
Arduino Overview:
![Page 9: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/9.jpg)
9
- Compile and Upload your code
- Verify blink is every 3 seconds then…
- Click Serial Monitor icon
Arduino Overview:
![Page 10: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/10.jpg)
10
- “LED is 1 or 0” correspond with on or off of LED?
Arduino Overview:
![Page 11: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/11.jpg)
11
- Now let’s modify our sketch to add an analog input
- Let’s use the potentiometer from HW #4
Arduino Overview:
![Page 12: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/12.jpg)
12
- Connect the Red wire to +5V, Black to GND, and White to A0
Arduino Overview:
![Page 13: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/13.jpg)
13
- Leave the LED connected to pin 9 but it won’t blink
Arduino Overview:
![Page 14: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/14.jpg)
14
- Modify your sketch to add the following variable
Arduino Overview:
![Page 15: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/15.jpg)
15
- Modify your sketch to add the following to your loop- Comment out all LED blink and Serial Print for LED
Arduino Overview:
![Page 16: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/16.jpg)
16
- Compile and Upload your code
- Click Serial Monitor icon
Arduino Overview:
![Page 17: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/17.jpg)
17
- “A0 is ” should change as you turn the potentiometer
Arduino Overview:
![Page 18: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/18.jpg)
18
- What does this number mean?
- What resolution is it? 8 bit, 10 bit, 16 bit?
- Modify sketch to Serial Print both 10 bit value and corresponding voltage value
- Recompile and upload
- Tinker until everyone is at this point
Arduino Overview:
![Page 19: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/19.jpg)
19
- Let’s connect the A0 to the LED with software
- Turn your potentiometer fully counterclockwise
- What do you think will happen?
Arduino Overview:
![Page 20: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/20.jpg)
20
- Modify sketch to add the following line:
Arduino Overview:
![Page 21: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/21.jpg)
21
- Compile and Upload
- Activate Serial Monitor
- Begin turning potentiometer clockwise
- What happens?
- Why?
- 10 bit vs. 8 bit? 255 vs 1023? Look at the monitor…
Arduino Overview:
![Page 22: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/22.jpg)
22
- When 255 is hit, resets
- Let’s map our 10 bit analog to a 8 bit digital
- Add the following variable to your sketch
Arduino Overview:
![Page 23: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/23.jpg)
23
- Add the following lines to your loop
Arduino Overview:
![Page 24: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/24.jpg)
24
- Compile and Upload
- Activate Serial Monitor
- Begin turning potentiometer clockwise
- What happens?
- 255 = 1023?
Arduino Overview:
![Page 25: 1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:](https://reader038.fdocuments.us/reader038/viewer/2022102702/5697bfee1a28abf838cb9855/html5/thumbnails/25.jpg)
25
- Potentiometer is acting like an analog sensor
- We can now hook up any analog sensor and see its value (at least through serial)
- What other sensors can we hook up?
- Let’s add some…
- But first let’s add the Protoshield
Arduino Overview: