1 of 20 core arduino workshop chris koehler and brian sanders colorado space grant consortium

22
1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

Upload: tabitha-griffith

Post on 13-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

1 of 20

Core Arduino Workshop

Chris Koehler and Brian SandersColorado Space Grant Consortium

Page 2: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

2 of 20

Part 3 – Arduino Road Trip

A. Temperature Sensor

2

Page 3: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

vArduino Uno

Temperature Sensor:

PC/MacMonitor LEDs

Pot/Other

Infrared

Temp

3

Page 4: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

4

- The potentiometer is an analog sensor

- Almost all analog sensors work and are connected in the same way

- Let’s use hook up one more

- To do so will require another breadboard, with nicer features

Temperature Sensor:

Page 5: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

5

Temperature sensor is theTMP36 - Temperature Sensor

Temperature Sensor:

Page 6: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

6

- This breadboard has power and ground rails- Individual points on rails (rows) are connected- One rail, and its points, are independent of other rails

Temperature Sensor:

Page 7: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

7

- Also has numbers and letters to coordinate builds

Temperature Sensor:

Page 8: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

8

- Place in new breadboard exactly as shown

Temperature Sensor:

Page 9: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

9

- 5V (pin 1) = E3- Data (pin 2) = E2- GND (pin 3) = E1

Note orientation of sensor package

Temperature Sensor:

5 V

Data GND

Page 10: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

10

- Connect 5V from Arduino to “+” power rail

- Connect GND from Arduino to “-” rail

Temperature Sensor:

Page 11: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

11

- Connect 5V from Arduino to “+” power rail

- Connect GND from Arduino to “-” rail

Temperature Sensor:

Page 12: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

12

- Now all pins on “+” rail are connected to 5 Volts

- All “-” are connected to GND

Temperature Sensor:

Page 13: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

13

- Connect 5V and GND from rails to sensor

5V to A3

GND to A1

Temperature Sensor:

Page 14: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

14

- Connect A0 from Arduino to A2 on Bread-board

Temperature Sensor:

Page 15: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

15

- What do we need to change in the Sketch?

Temperature Sensor:

Page 16: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

16

- Nothing! But the Temp Sensor Voltage commands all LEDs off

- Build and Upload the code and look at serial monitor

- Should see ~0.73 Volts, which is well below our first LED turn on value of 1.25 Volts in the current IR sensor Sketch

Temperature Sensor:

Page 17: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

17

- To understand and set the proper range, let’s consult the data sheet for the sensor

- 10 mV/C (0.010V/C)

Temperature Sensor:

Page 18: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

18

- Data sheet also says there is an offset

- For TMP36,Offset = 0.5 Volts

Temperature Sensor:

Page 19: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

19

- So to understand the data, we need to do some math to convert voltage to C and set our ranges

Using what we are seeing from our serial monitor, 0.73 Volts, we would get…

Temperature Sensor:

Page 20: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

20

- Change the Sketch to do the math and change LED turn on ranges to temperatures of 21, 22, 23, and 24 C.

- Will need a new variable (float)

Temperature Sensor:

Page 21: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

21

- New variable, tempC (float)

- Add your math

- Modify your print statements

Temperature Sensor:

Page 22: 1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium

22

- Adjust your range settings for the LEDs

- Build and Upload

- Test by touching your temp sensor

- Challenge while you wait… Convert to Fahrenheit

Temperature Sensor:

PLEASE SAVE YOUR

SKETCH FILE