Lab: Sensor change detection

Benedetta had recommended that we do this lab. Truthfully, I’m not sure why detecting the change in voltage output overtime is very useful. ¬†Here are a few other questions I have:

  • How long should the detection time be?
  • How to detect the noise value of an analog sensor?

Digital sensor

Since digital sensors can only sense two states, what’s important¬†for detecting digital sensor change are the rising and falling edges.

Screen Shot 2014-09-26 at 8.59.37 PM

Circuitry for detecting digital sensor change.

Circuitry for detecting digital sensor change.

Digital sensor reading.

Digital sensor reading.

To detect the state change, we need to store the current state of a button as well as the previous state:

Analog sensor

It’s more complicated with analog sensor detection. We need to detect the peak value from the sensor. Like with the digital sensor, both the current and the previous states are tracked. To find the peak, we pick a threshold that would be below the peak. Each time the sensor value rises above the peak, the sensor value is stores as the peak. This happens continuously until the peak value is always above the sensor value.

Analog sensor change.

Analog sensor change.

Circuitry for analog sensor change detection.

Circuitry for analog sensor change detection.

Reading analog sensor change. The LED light up every AFTER the sensor has peaked.

Reading analog sensor change. The LED light up every AFTER the sensor has peaked.

With analog sensors there are often noise in the sensor reading that interfere with peak readings. To remove the noise, the code is modified as such: