Skip to content

11. Input Devices: Richard Shan & Connor Cruz

Assignment

For this week, we were assigned to probe an input device’s analog levels and digital signals.

Work Distribution

People Description
Richard Camera Measurements
Connor Step Response Measurements
All Documentation
All Oscilloscope Wrangling
All Step Response Wrangling

Camera Facial Recognition Digital Measurement

We used the ESP32 Camera Board as a sensor that would power an LED when it detects a face in the camera’s view. Full documentation on the implementation of the facial recognition sensor can be found here, but essentially the LED lights up when a face is detected.

Because the LED had only two states: on when a face is detected and off when there are no faces, we used camera sensor for digital readings.

In the following video of our test, the camera was always pointed at my face, so there was always a face detected and power being sent to the LED. Excepting the short pauses which were when the camera takes and analyzes a new picture, the LED is always on as there is always a face in view.

The oscilloscope reading exemplifies the always-on-with-interruptions digital state of the LED as the screen shows longer segments of high voltage where the LED is on being interrupted by short pauses of low voltage where the LED is off while a new image is processed.

Step Response Sensor Analog Read

The step response sensor returns an analog value, and in this case, we used it to determine proximity to a surface (we used the glorious book, Cicero In Catilinam I & II). I did get this to have a digital output on my individual documentation, but we were more focused on analog reading. To read the analog output of the step response sensor and have a visual representation at the same time, we mapped the sensor’s approximate range to the values 0-255, planning to apply these to change the brightness of an LED. Here is the function I made to do this:

void analogLED() {
  long int avg = average();
  int newAvg = map(avg, 10000, 15000, 0, 255);
  analogWrite(4, 255 - newAvg);
}

We implemented this function into the code for the step response sensor, and it worked successfully. As we lowered a hand onto the book, the LED got brighter, and as we raised it up, the LED dimmed. There was a slight amount of noise when the hand was not placed on top of the book, but we disregarded this for the purposes of measuring. After connecting an oscilloscope to the ground and the PWM pin connected to the LED, the reading on the oscilloscope matched the changing brightness of the LED:

Since PWM simply emulates analog, we can see that as the hand gets closer to the book, there are more high signals. This causes the LED to appear brighter.


Last update: April 18, 2024