5,710
edits
Changes
→Activities
By default, the ''AnalogInput'' program expects the potentiometer to be connected on Analog In 0, the value of <code>sensorPin</code> variable at the top of the program.
==== Photoresistor ====
Use the photoresistor from your 147A kit (which has a resistance between 800 Ohms - 140 KOhms depending on your lighting conditions) and build the simple photoresistor voltage divider circuit above.
QUESTIONS: * With the same R2 resistor (10k) from above, replacing R1 with the photoresistor, what would you expect the highest and lowest voltage to be output from the simple photoresistor circuit? highest ** Highest ____V, lowest Lowest ____V. *The important part of this sketch is the line where the microprocessor reads the analog input <code>sensorValue = analogRead(sensorPin).</code> Looking at the Arduino reference for that function (<code>analogRead()</code>), what do you think the value <code>sensorVal</code> will be for those highest and lowest voltages from the photoresistor circuit? Remember, <code>analogRead()</code> returns a number between 0-1023. ** <code>sensorVal</code>: highest ____, lowest ____. * Verify your answers for the voltage and <code>sensorVal</code> values questions above. You can build the circuit and measure the voltage directly, but getting the <code>sensorVal</code> data is a little more complex. You can use Try using concepts from next weeks material 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...
==== Other Sensors ====