9. Input devices

Group Assignement

This week I learned how to test, read and integrate input devices into my PCBs.
Some of of my learnings:



My process for this week's assignement was a little improvised and chaotic but it turned out great (and it was really fun)

  1. First I started designing a brand new PCB from scratch because I though I had 2 microcontrolers (one used for ñast last week's assignement, another one left)...
  2. Turned out I lost or didn't get the second microcontroler, so I decided to reuse last week's PCB and see if I could just add the sensor.
  3. I analyzed my micronphone sensor, measured, played around with orientation and sketched some paths with marker over the acrilic. It all looked good in theory XD I just had to use the other phase of the acrilic, creating my own DIY inter-phase paths.
  4. Made the holes I needed to connect the 3 pins of my microphone sensor: OUT, GND and V. Thinking it shouldn't be too complicated, fully trusting my soldering skills and my vision.
  5. Added some single pins and copper tape from last week's spare cut manually to create my tracks. (Crossing my fingers with every move)
  6. Tested every connection and made any necessary adjustments
  7. Secured and covered all important (or loose) connections with silicone to get the final PCB
  8. Uploaded a new Code to the microcontroler
  9. Some important notes about the code:

    1. INPUT_PULLUP

      In this code, the line pinMode(buttonPin, INPUT_PULLUP); configures the button pin as an input with the ESP32's internal pull-up resistor enabled. This keeps the pin at a stable HIGH state when the button is not pressed, preventing random or false readings caused by electrical noise. When the button is pressed, the pin is connected to GND and reads LOW. Using INPUT_PULLUP eliminates the need for an external resistor, simplifying the circuit and making button detection more reliable.

    2. Analog Reading

      The analogRead() function is essential because it converts the microphone's analog voltage signal into a digital value that the microcontroller can process. This allows the ESP32 to read changes in sound intensity and use those values to trigger actions in the system.

    3. Threshold Detection

      The threshold value is important because it defines the minimum sound level required to trigger an action. This helps filter out background noise and ensures that only intentional or stronger sounds are detected by the system.

    4. Serial Monitoring

      Serial monitoring was useful during development to visualize the microphone readings in real time. This made it easier to test the sensor, understand the range of values, and choose an appropriate threshold for the environment.

  10. Tested and calibrated the sensor
  11. Got my hacked pcb working :D

I'm so happy and proud I made this work.


For my final project...

I am using a HC SR501 PIR Motion Sensor

Go to final project page to see more of it's implementation.

Download all files