Changes

Jump to: navigation, search

Classes/2010/VIS147A/Lab8

613 bytes removed, 15:48, 2 March 2010
Activities
** <code>sensorVal</code>: highest ____, lowest ____.
* Verify your answers for the questions above. You can build the circuit and measure the voltage directly, but getting the <code>sensorVal</code> data is a little more complex. Try using concepts from next week's class (''Examples->Communication'') or just the basic <code>Serial.println()</code> we discussed in class.
* How could you make this more sensitive? There are least three ways to try... think in terms of the physical enclosure around the sensor, the hardware setup (a voltage divider), and the software (look at File->Sketchbook->''Analog->Calibration''..., specifically the <code>map()</code> function)
** Does changing the code make this more sensitive? The voltage range of the input is staying the same, the number representing it does not...
[[Image:LED_FADER.JPG|400px]]
* It looks like a MacBook napping...* Get this working. Then...* Q: Drive this dimming example with the light sensor from before. ** use <code>analogRead()</code> to get the value from the sensor, like you did before, then use <code>analogWrite()</code> to output the value to the LED. NOTE: <code>analogRead()</code> will return values from 0-1023, and <code>analogWrite()</code> writes values from 0 to 255, so you will need to divide your read value by 4 to get the output value. Or you could use <code>map()</code> * Q3.1: Does yours turn on when it is light, or does it turn off? Switch this to give it the opposite behavior, in either hardware or software. You could do either!
Get this working. === == Drive a Lightbulb =====
Same as the LED, but with a higher current load: your microprocessor can not source enough current to power the bulb. (Or maybe it can, but you probably don't want to test it!) We need to use a power transistor: TIP120. This allows you to control a larger current (the bulb) with a smaller current (digital out from the chip).
[[Image:Lamp_fader.png]] [[Image:BULB.JPG|400px]]
[[Image:BULB.JPG|400px]] === == Drive a Motor / Speed Control =====
* Basic motor speed control (for a DC motor).
* Same circuit as above, swapping the motor for the lamp.
[[Image:MOTOR_SPEED.JPG|400px]]
Q: Drive it ==== Analog Input driving Analog Output ====Combing your ''AnalogInput'' and ''Fading'' code to drive the fading/speed-control circuit with the input potentiometer. Use <code>analogRead()</code> to get the value from the sensor, like you did before, then use <code>analogWrite()</code> to output the value to the LED. NOTE: <code>analogRead()</code> will return values from 0-1023, and <code>analogWrite()</code> writes values from 0 to 255, so you will need to divide your read value by 4 to get the potentiometeroutput value. Or you could use <code>map()</code>===== Photoresistor driving Motor =====
=== Sound/Tone Generation! For Sound People (optional) ===An analog output, different Drive this circuit with the input from the light dimmerphotoresistor. To make a varying sound, you would want to change the frequency of the output signal, not the amplitude.* This Does yours motor turn on when it is more like the light blinking from part one, where changing the input voltage will change the rate of the light. or does it turn off? But now you will do it with a Piezo, adjusting the time delay in microseconds. * If you like sound, try Switch this: http://www.arduino.cc/en/Tutorial/PlayMelody, I have a piezo you can use. (Or you can get one at RadioShack).* This example adjusts the frequency of to the output (tone) not opposite behavior by rewriting the magnitude. * the light fading above (<code>analogWrite()</code>) adjusts running on the brightness of the light (magnitude) with PWMprocessor.
== Homework ==

Navigation menu