- now let’s modify our sketch to add an analog input - let’s use the potentiometer from hw #4
DESCRIPTION
Arduino Overview:. - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4. Arduino Overview:. - Connect the Red wire to +5V, Black to GND, and White to A0. Arduino Overview:. - Leave the LED connected to pin 9 but it won’t blink. Arduino Overview:. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/1.jpg)
1
- Now let’s modify our sketch to add an analog input
- Let’s use the potentiometer from HW #4
Arduino Overview:
![Page 2: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/2.jpg)
2
- Connect the Red wire to +5V, Black to GND, and White to A0
Arduino Overview:
![Page 3: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/3.jpg)
3
- Leave the LED connected to pin 9 but it won’t blink
Arduino Overview:
![Page 4: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/4.jpg)
4
- 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:
![Page 5: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/5.jpg)
5
- Take out the Protoshield your team built in HW#4
Arduino Overview:
![Page 6: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/6.jpg)
6
- Carefully connect it with your unpowered Uno
Arduino Overview:
![Page 7: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/7.jpg)
7
- Carefully connect it with your unpowered Uno
Arduino Overview:
![Page 8: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/8.jpg)
8
- Carefully connect it with your unpowered Uno
Arduino Overview:
![Page 9: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/9.jpg)
9
- Carefully connect it with your unpowered Uno
Arduino Overview:
![Page 10: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/10.jpg)
10
- Reconnect Uno to laptop and verify all is working
- Activate Serial Monitor
Arduino Overview:
![Page 11: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/11.jpg)
11
- Disconnect LED Breadboard and connect wire from pin 9 to JC3 on ProtoShield
- Activate Serial Monitor
Arduino Overview:
![Page 12: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/12.jpg)
12
- Carefully move wire to JC3 to JC2…
Arduino Overview:
![Page 13: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/13.jpg)
13
- Add the Temperature Sensor to the Breadboard
Arduino Overview:
![Page 14: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/14.jpg)
14
- Connect Pin 1 to 5V
Arduino Overview:
![Page 15: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/15.jpg)
15
- Connect Pin 3 to GND
Arduino Overview:
![Page 16: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/16.jpg)
16
- Connect Pin 2 to A5
Arduino Overview:
![Page 17: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/17.jpg)
17
- Modify your sketch to add the following variable
Arduino Overview:
![Page 18: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/18.jpg)
18
- Modify your sketch to add the following lines in loop
Arduino Overview:
![Page 19: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/19.jpg)
19
- Compile and Upload
- Activate Serial Monitor
- Test by putting your finger on the sensor
- Do you see a change?
Arduino Overview:
![Page 20: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/20.jpg)
20
- Convert to Voltage and display on Serial Monitor
Arduino Overview:
![Page 21: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/21.jpg)
21
- Should see this…
Arduino Overview:
![Page 22: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/22.jpg)
22
- Use spec sheet to convert to degrees C
- 10 mV/C
- Look for offset
Arduino Overview:
![Page 23: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/23.jpg)
23
- 0.5 V offset
Arduino Overview:
![Page 24: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/24.jpg)
24
- Modify your sketch
Arduino Overview:
![Page 25: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/25.jpg)
25
- Should see this…
Arduino Overview:
![Page 26: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/26.jpg)
26
- Data make sense?
- How would you calibrate this sensor?
Arduino Overview:
![Page 27: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/27.jpg)
27
- Add the Humidity Sensor to the Breadboard
Arduino Overview:
![Page 28: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/28.jpg)
28
- Connect 5 V from Temp Sensor
Arduino Overview:
![Page 29: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/29.jpg)
29
- Connect GND from Temp Sensor
Arduino Overview:
![Page 30: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/30.jpg)
30
- Connect Out to A4
Arduino Overview:
![Page 31: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/31.jpg)
31
- Modify Sketch
Arduino Overview:
![Page 32: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/32.jpg)
32
- Should get…
Arduino Overview:
![Page 33: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/33.jpg)
33
- Convert to voltage and understandable units from data sheet
- Algebra
Arduino Overview:
![Page 34: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/34.jpg)
34
- Modify Sketch
Arduino Overview:
![Page 35: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/35.jpg)
35
- Should get…
Arduino Overview:
![Page 36: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/36.jpg)
36
- Data make sense?
- How would you calibrate this sensor?
Arduino Overview:
![Page 37: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/37.jpg)
37
- Add the Accelerometer to the Breadboard
Arduino Overview:
![Page 38: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/38.jpg)
38
- Connect 3.3V to Vcc from UNO
Arduino Overview:
![Page 39: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/39.jpg)
39
- Connect GND to GND from Humidity Sensor
Arduino Overview:
![Page 40: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/40.jpg)
40
- Connect ZOUT to A3 on UNO
Arduino Overview:
![Page 41: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/41.jpg)
41
- Connect YOUT to A2 on UNO
Arduino Overview:
![Page 42: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/42.jpg)
42
- Connect XOUT to A1 on UNO
Arduino Overview:
![Page 43: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/43.jpg)
43
- Accelerometer has a few other settings we need address from the Data Sheet
Arduino Overview:
![Page 44: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/44.jpg)
44
- Sleep…Connect 3.3V from Accel Vcc to SLP
Arduino Overview:
![Page 45: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/45.jpg)
45
- Range…Connect 3.3V from Accel Vcc to GSEL
Arduino Overview:
![Page 46: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/46.jpg)
46
- Modify Sketch as follows
Arduino Overview:
![Page 47: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/47.jpg)
47
- Modify Sketch as follows
Arduino Overview:
![Page 48: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/48.jpg)
48
- Should get…
Arduino Overview:
![Page 49: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/49.jpg)
49
- Convert to voltage and understandable units from data sheet
- Algebra
Arduino Overview:
![Page 50: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/50.jpg)
50
- Convert to Voltage = accelX * (5.0/1024)
- Subtract offset and convert to GsGs = (voltage – 1.65) / (0.206)
Arduino Overview:
![Page 51: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/51.jpg)
51
Arduino Overview:
- Modify Sketch as follows
![Page 52: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/52.jpg)
52
Arduino Overview:
- Modify Sketch as follows
![Page 53: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/53.jpg)
53
Arduino Overview:
- Should get…
![Page 54: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/54.jpg)
54
Arduino Overview:
- Hold X flat, should see 0 G
![Page 55: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/55.jpg)
55
Arduino Overview:
- Hold X arrow pointing up, should see 1.0 G
![Page 56: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/56.jpg)
56
Arduino Overview:
- Hold X arrow pointing down, should see - 1.0 G
![Page 57: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/57.jpg)
57
Arduino Overview:
- Repeat with Y and Z axes
- May need to tape breadboard down
- Do you need to Calibrate?
- How would you do it?
![Page 58: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/58.jpg)
58
- Add the Pressure Sensor to the Breadboard- Notice orientation
Arduino Overview:
![Page 59: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/59.jpg)
59
- Add the Pressure Sensor to the Breadboard- Notice orientation
Arduino Overview:
![Page 60: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/60.jpg)
60
- Connect Pin 2 to 5.0 Volts from your Humidity Sensor
Arduino Overview:
![Page 61: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/61.jpg)
61
- Connect Pin 4 to GND from your Humidity Sensor
Arduino Overview:
![Page 62: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/62.jpg)
62
- Connect Pin 3 to A0 on your UNO
Arduino Overview:
![Page 63: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/63.jpg)
63
- Modify your sketch…
Arduino Overview:
![Page 64: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/64.jpg)
64
- Modify your sketch…
Arduino Overview:
![Page 65: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/65.jpg)
65
- Compile and upload. Should see…
Arduino Overview:
![Page 66: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/66.jpg)
66
- Use ¼ sprinkler tubing to suck on pressure sensor
- Do not blow as limit of this sensor is 15 psi
Arduino Overview:
![Page 67: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/67.jpg)
67
- Convert to voltagepV=A0*(5.0/1024)
- Use spec sheet to solve for psi (Algebra)
Pmax = 15 psiPmin = 0Vsupply = 5.0 VOutput(V) = pV
Arduino Overview:
![Page 68: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/68.jpg)
68
- Solve for Pressure(applied) = Pa
Pa = psi = (pV – (.1 * 5.0)) / (.8*5.0) / (15-0) psi = (pV – .5) / (.4 / 15)
Arduino Overview:
![Page 69: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/69.jpg)
69
- Modify your sketch…
Arduino Overview:
![Page 70: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/70.jpg)
70
- Modify your sketch…Suggest commenting out your accel and other sensor Serial.print statements
Arduino Overview:
![Page 71: - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4](https://reader036.vdocument.in/reader036/viewer/2022062808/5681548f550346895dc29f3e/html5/thumbnails/71.jpg)
71
- Should see this…
- Suck to zero?
Arduino Overview: