Olenka Odar - Fab Academy

13 Input Devices

In this section we list the activities to be solved in the following table:

Checklist Estatus
Linked to the group assignment page Finished
Documented what you learned from interfacing an input device(s) to your microcontroller and how the physical property relates to the measured results. Finished
Documented your design and fabrication process or linked to the board you made in a previous assignment. Finished
Explained the programming process/es you used. Finished
Explained any problems you encountered and how you fixed them.  Finished 
Included original design files and source code. Finished
Included a 'hero shot' of your board. Finished

Individual assignment 

Measure something: add a sensor to a microcontroller board that you have designed and read it.

For this part I will use the FAB XIAO RP2040 board that I made in electronic production and the following sensors:

HC SR501 PIR Motion Sensor

Passive Infrared (PIR) motion sensor used to detect movement of people or warm objects. It works by using two infrared sensors that detect changes in infrared radiation in your field of vision.

learn more

35MM Piezoelectric Sensor

They are used as vibration or shock sensors, since they allow the applied pressure to be converted to a voltage.

learn more

KY-038 Sound Sensor 

Used to detect sound, it uses a highly sensitive cylindrical microphone. It has an analog output and a digital output.

learn more

Hello PIR

The PIR sensor has three pins for its connection as shown in the image, it works at 5VDC, but its output signal is 0V (low level) and 3.3V (high level). The output signal will be connected to pin D0 of my Fab Xiao card.  It is also necessary to regulate the sensitivity and the time between measurements (delay). In this image you can see the "object detected" / "object not detected" message using the arduino serial monitor. In this image you can see the behavior of the sensor's output signal every time the object is detected, for this I use the "serial plotter" option of arduino. Observe how the width of the square wave varies, when changing with the potentiometer, the duration of the pulse.

Hello PIEZO_LED

The connection of this sensor is simple, the black cable will be connected to GND and the red cable to the analog input A1. The program consists of making the led that is incorporated in my board (D6) blink and when I press the sensor the blinking stops.

Hello PIEZO_RGB LED 

For this example I used rgb led that is built into the XIAO RP2040 card, whose activation pins are 11 for Power and 12 for LED control. The piezoelectric sensor will continue to be connected to analog input A1.

When pressing the sensor the rgb led will show white light, when the sensor is not pressed it will vary between four different colors of light.

In both cases, using the arduino serial monitor, you can see how the value sent to the analog pin A1 varies when the piezoelectric sensor is pressed or not.

Final Project Test

KY-038 Sound Sensor + WS2812B Led Strip

The sound sensor has 4 connection pins: an analog output pin, a digital output pin, and two for power. I used the digital pin of the sound card (since I want each time it receives a signal to activate the led strip in a different way) and I connected it to pin D1 of the card and I connected the led strip to pin D8.

For my project I need that every time the sound sensor detects a signal, it allows the LEDs to be turned on in different shapes and colors. At first I thought of activating the sensor by clapping, but my daughter made me realize something: "mom at night while they are asleep the clapping will wake them up, what if we blow?" So based on her suggestion I did the tests. Here's a video of it working.

My program and my circuit work correctly.

Group assignment:

  • Probe an input device(s)’s analog and digital signals
  • Document your work on the group work page and reflect on your individual page what you learned

I will also do this assignment individually.

Sound sensor + oscilloscope

For this assignment, since the sound sensor has analog and digital output pins, I'll use this sensor.

Measurements on digital output pin

As can be seen, the output signal of the D0 pin of the sensor are square waves characteristic of a digital signal.

Measurements on the analog output pin

The images show the output signal from pin A0 of the sensor; a time-varying signal can be seen depending on the intensity of the signal detected by the sound sensor. This type of waveform is characteristic of an analog signal.

The video on the left shows the behavior of the sensor's digital output signal and the video on the right shows the behavior of the analog output signal.

Drawbacks, solutions and what I learned

  • To work with the PIR sensor, its calibration time must be taken into account (varies from 10 to 60 seconds), during which time the sensor "learns" to recognize the state of rest or the state of movement of the environment. In my case I considered 60 seconds with the following program line: 
    • for(int i = 0; i > 60; i++) // sensor calibration time
  • To work with the RGB led that the card incorporates, do not forget that we must have the Adafruit NeoPixel library installed.
  • The supply voltage of the sound sensor goes from 3 to 24V, in the test with the led strip I connected it to 3.3V.
  • Before working with the sound sensor, it must be calibrated. When we connect the sensor for the first time, LED2 that is near the potentiometer stays on, we must regulate the potentiometer until LED2 turns off. Once this procedure is done, we can begin to regulate the sensitivity of the sensor.

Programs

   12.   14 .