Analog Sensors Activities and Notes:

This week there were a range of questions generated by student explorations since last we met. We took the time to walk around the room and sort out individual concerns. Some turned out to be syntax in the sketch - this is a common challege for all of us - and a few wiring challenges.

We then approached the question of how the analog inputs (there are 6 numbered 0-5 on the Uno board) differ from digital pins. In it's simplest form the analog pins can be thought as voltage measuring pins. The Uno 'looks' at the pin and determines the voltage it sees (default range is 0 - 5V) and converts that to a 10 bit number between 0 and 1023 (210 = 1024). It is important to be sure to limit the voltage at the analog pin to 5V to avoid damage to the Uno board. Refer to the datasheet for other relevant and important limits on the I/O pins.

We also discussed the importance of data sheets in understanding the devices and objects that we use to build our test circuits. The case in question was the PN2222 transistor which we had briefly discussed last week. As it turns out some folks have a P2N2222 transistor in their kit which certainly seems like it should be similar. A careful read of the data sheets indicates the the pins/legs on the PN2222 are numbered differently than the P2N2222 (reversed actually) which has to be accounted for in your circuits.

We then walked through the process of using a potentiometer to control the voltage at an analog pin. In the sketch we wrote that measured voltage to the serial monitor. This got us thinking about how to convert from the 10 bit number that the Uno reports to us and the actual voltage. Also got us some more experience with the challenges of wiring up test circuits and debugging them.

Finally we explored some demonstrations of the TMP 36 temperature sensor and a CdS (cadmium sulfide) photosensor. Using a variation of Jeremy's nightlight sketch we converted the analog output of the TMP 36 temperature sensor to mV and then to degrees centigrade. We discussed the idea of calibration of sensors and how to accomodate it in the sketch.

Everyone was encouraged to build their own temperature or light sensor that would use the RGB LED to indicate whether the measurement was in the desired range or too high or too low. The enthusiastic student will consider how to write a sketch that makes a decision based on two sensors. Such a tool is used in gas furnaces (a much simpler implementation I admit) to keep the gas on when a photosensor sees a flame and a temperature sensor detects the heat from the pilot light. If the flame goes out the gas is shut off and won't restart unless the pilot is still running. Have fun.....!