1 - now let’s modify our sketch to add an analog input - let’s use the potentiometer from hw #4...

71
1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

Upload: ella-freeman

Post on 02-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

1

- Now let’s modify our sketch to add an analog input

- Let’s use the potentiometer from HW #4

Arduino Overview:

Page 2: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

2

- Connect the Red wire to +5V, Black to GND, and White to A0

Arduino Overview:

Page 3: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

3

- Leave the LED connected to pin 9 but it won’t blink

Arduino Overview:

Page 4: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

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: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

5

- Take out the Protoshield your team built in HW#4

Arduino Overview:

Page 6: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

6

- Carefully connect it with your unpowered Uno

Arduino Overview:

Page 7: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

7

- Carefully connect it with your unpowered Uno

Arduino Overview:

Page 8: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

8

- Carefully connect it with your unpowered Uno

Arduino Overview:

Page 9: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

9

- Carefully connect it with your unpowered Uno

Arduino Overview:

Page 10: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

10

- Reconnect Uno to laptop and verify all is working

- Activate Serial Monitor

Arduino Overview:

Page 11: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

11

- Disconnect LED Breadboard and connect wire from pin 9 to JC3 on ProtoShield

- Activate Serial Monitor

Arduino Overview:

Page 12: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

12

- Carefully move wire to JC3 to JC2…

Arduino Overview:

Page 13: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

13

- Add the Temperature Sensor to the Breadboard

Arduino Overview:

Page 14: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

14

- Connect Pin 1 to 5V

Arduino Overview:

Page 15: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

15

- Connect Pin 3 to GND

Arduino Overview:

Page 16: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

16

- Connect Pin 2 to A5

Arduino Overview:

Page 17: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

17

- Modify your sketch to add the following variable

Arduino Overview:

Page 18: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

18

- Modify your sketch to add the following lines in loop

Arduino Overview:

Page 19: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

19

- Compile and Upload

- Activate Serial Monitor

- Test by putting your finger on the sensor

- Do you see a change?

Arduino Overview:

Page 20: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

20

- Convert to Voltage and display on Serial Monitor

Arduino Overview:

Page 21: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

21

- Should see this…

Arduino Overview:

Page 22: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

22

- Use spec sheet to convert to degrees C

- 10 mV/C

- Look for offset

Arduino Overview:

Page 23: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

23

- 0.5 V offset

Arduino Overview:

Page 24: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

24

- Modify your sketch

Arduino Overview:

Page 25: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

25

- Should see this…

Arduino Overview:

Page 26: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

26

- Data make sense?

- How would you calibrate this sensor?

Arduino Overview:

Page 27: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

27

- Add the Humidity Sensor to the Breadboard

Arduino Overview:

Page 28: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

28

- Connect 5 V from Temp Sensor

Arduino Overview:

Page 29: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

29

- Connect GND from Temp Sensor

Arduino Overview:

Page 30: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

30

- Connect Out to A4

Arduino Overview:

Page 31: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

31

- Modify Sketch

Arduino Overview:

Page 32: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

32

- Should get…

Arduino Overview:

Page 33: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

33

- Convert to voltage and understandable units from data sheet

- Algebra

Arduino Overview:

Page 34: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

34

- Modify Sketch

Arduino Overview:

Page 35: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

35

- Should get…

Arduino Overview:

Page 36: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

36

- Data make sense?

- How would you calibrate this sensor?

Arduino Overview:

Page 37: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

37

- Add the Accelerometer to the Breadboard

Arduino Overview:

Page 38: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

38

- Connect 3.3V to Vcc from UNO

Arduino Overview:

Page 39: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

39

- Connect GND to GND from Humidity Sensor

Arduino Overview:

Page 40: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

40

- Connect ZOUT to A3 on UNO

Arduino Overview:

Page 41: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

41

- Connect YOUT to A2 on UNO

Arduino Overview:

Page 42: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

42

- Connect XOUT to A1 on UNO

Arduino Overview:

Page 43: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

43

- Accelerometer has a few other settings we need address from the Data Sheet

Arduino Overview:

Page 44: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

44

- Sleep…Connect 3.3V from Accel Vcc to SLP

Arduino Overview:

Page 45: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

45

- Range…Connect 3.3V from Accel Vcc to GSEL

Arduino Overview:

Page 46: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

46

- Modify Sketch as follows

Arduino Overview:

Page 47: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

47

- Modify Sketch as follows

Arduino Overview:

Page 48: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

48

- Should get…

Arduino Overview:

Page 49: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

49

- Convert to voltage and understandable units from data sheet

- Algebra

Arduino Overview:

Page 50: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

50

- Convert to Voltage = accelX * (5.0/1024)

- Subtract offset and convert to GsGs = (voltage – 1.65) / (0.206)

Arduino Overview:

Page 51: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

51

Arduino Overview:

- Modify Sketch as follows

Page 52: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

52

Arduino Overview:

- Modify Sketch as follows

Page 53: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

53

Arduino Overview:

- Should get…

Page 54: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

54

Arduino Overview:

- Hold X flat, should see 0 G

Page 55: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

55

Arduino Overview:

- Hold X arrow pointing up, should see 1.0 G

Page 56: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

56

Arduino Overview:

- Hold X arrow pointing down, should see - 1.0 G

Page 57: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

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: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

58

- Add the Pressure Sensor to the Breadboard- Notice orientation

Arduino Overview:

Page 59: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

59

- Add the Pressure Sensor to the Breadboard- Notice orientation

Arduino Overview:

Page 60: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

60

- Connect Pin 2 to 5.0 Volts from your Humidity Sensor

Arduino Overview:

Page 61: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

61

- Connect Pin 4 to GND from your Humidity Sensor

Arduino Overview:

Page 62: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

62

- Connect Pin 3 to A0 on your UNO

Arduino Overview:

Page 63: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

63

- Modify your sketch…

Arduino Overview:

Page 64: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

64

- Modify your sketch…

Arduino Overview:

Page 65: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

65

- Compile and upload. Should see…

Arduino Overview:

Page 66: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

66

- Use ¼ sprinkler tubing to suck on pressure sensor

- Do not blow as limit of this sensor is 15 psi

Arduino Overview:

Page 67: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

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: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

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: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

69

- Modify your sketch…

Arduino Overview:

Page 70: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

70

- Modify your sketch…Suggest commenting out your accel and other sensor Serial.print statements

Arduino Overview:

Page 71: 1 - Now let’s modify our sketch to add an analog input - Let’s use the potentiometer from HW #4 Arduino Overview:

71

- Should see this…

- Suck to zero?

Arduino Overview: