- 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: zizi

Post on 27-Jan-2016

30 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

71

- Should see this…

- Suck to zero?

Arduino Overview: