Gene Lu

Lab Analog Input
Friday, 25 September 2009

Connect Power from Arduino to Breadboard
We hook up both power (red rail) and ground buses (blue) on the breadboard to each other. We then hook up 5V and ground from the Arduino board into their respective buses on the breadboard.

Arduino hooked up to the breadboard
Arduino hooked up to the breadboard

Connect Potentiometer and Upload Program and Play
Afterwards, we connect the potentiometer used in the last lab into the circuit. This will provide the analog input into the Arduino board. Once connected and our program uploaded to the board, the potentiometer will adjust the brightness of the LED as well as change the value of the 'val' variable in Arduino's serial monitor from 0 to 1023. The brighter the LED, the higher the value of 'val'.

Also, it is important to note that a brighter LED is associated with a larger pulse width. This means that when we turn the knob on the potentiometer, we increase the voltage sent to the analog input of the board, which increases the pulse width, leading to a brighter LED.

With regards to the program uploaded, you will notice that we divide the variable 'val' by 4. This is because 'val', initially an analog input, is a 10-bit value (1024) and will eventually be converted into an analog output, which is an 8-bit value (256). In order to make the adjustment from input to output, we divide by 4. (1024/4 = 256).

Potentiometer in the circuit will provide analog input
Potentiometer in the circuit will provide analog input

Connect Another Variable Resistor into Circuit
In this circuit, I used the light dependent resistor (LDR) that came with the Physical Computing kit as my variable resistor. Since the potentiometer is intrinsically a voltage divider, I used a 10kΩ resistor in addition to the LDR. After connecting the resistors and running the Arduino program, we notice that the brightness of the LED changes based on how much light is present on the photocell resistor's surface. In this case, the more light on the photocell resistor, the brighter the LED.

Potentiometer - Voltage Divider
Potentiometer - Voltage Divider
LDR & Resistor - Voltage Divider
LDR & Resistor - Voltage Divider

Circuit with a photocell resistor
Circuit with a photocell resistor

Creating My Own Variable Resistor Circuit
Motivation for the What-To-Wear Thermometer

Whenever I visit my girlfriend, she would ask me, "What's the weather like outside?". I'd usually check my iPhone or just give an estimation off the top of my head. Unsatisified, she would then follow up with another question, "Is it like t-shirt or sweater weather?". She's not the only person I've heard that has asked about the weather in this way and so for this lab, I've created a what-to-wear thermometer that tells you just exactly that, what to wear.

How does it Work
In the what-to-wear thermometer, I ran a test on my analog input, in this case a thermistor, against several 'if' statements and conditionals. Before doing so, I had to figure out the number that would convert the input value on the thermistor to temperature value. To accomplish this, I left the thermistor undisturbed in the lab, which was around room temperature 77°F. By accessing the serial monitor in Arduino, I noted that the output was reading a value of 22. I divided 77/22, which gave me 3.5. So in order to get a value in degrees Farenheit, I multiplied the input value of the thermistor by 3.5. Although not as accurate as I'd like it to be, it gave me a decent approximation on the temperature in degrees Farenheit, which I would then use in my conditional statements.

Varying the Value of the Fixed Resistor
When we swap out the 10KΩ with a 1KΩ resistor, the voltage value where they connect jumps up significantly, which causes the LED to become brighter.

Here's the demo of the what-to-wear thermometer on youtube.

Schematics of the What-To-Wear Thermometer
Schematics of the What-To-Wear Thermometer

What-To-Wear Thermometer at Room Temperature (Warm)
What-To-Wear Thermometer at Room Temperature (Warm)

It's Hot - No Clothes!
It's Hot - No Clothes!
Warm - T-shirt Weather
Warm - T-shirt Weather

Cool - Sweater Weather
Cool - Sweater Weather
Cold - Jacket Weather
Cold - Jacket Weather

Post a Note
Name:
Website:
Title:
 
Security Image

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.

 
Velocity-Based Bike Light < Prev Post   Next Post > Lab Electronics