11. Input devices
Assignment:
Group assignment:
Probe an input device(s)'s analog and digital signals
Document your work (in a group or individually)
Individual assignment:
Measure something: add a sensor to a microcontroller board that you have designed and read it.
Planning
For this assignment, I decided to use the "Fab-Xiao-Guitar" board that I had previously designed, which already had a servo motor incorporated. Initially, I had thought of using some kind of motion sensor to move the servo, but I decided not to complicate things because the university was taken over by students in protest and the situation was unstable, meaning we didn't know how long we would have access to the lab. To fulfill the assignment as quickly as possible, I decided to use an IR receiver and a remote control to control the movement of the servo motor.
I used the KY-022 Infrared Receiver Module as an IR sensor, which is sensitive to 38KHz infrared light. It is compatible with many microcontrollers, including Arduino, Raspberry Pi, ESP32, among others. The module is composed of a 1838 IR receiver, a 1kΩ resistor, an LED, and 3 male header pins. Its technical specifications are as follows:
Operating Voltage 2.7V to 5.5V
Operating Current 0.4mA to 1.5mA
Reception Distance 18m
Reception Angle ±45º
Carrier Frequency 38KHz
Low Level Voltage 0.4V
High Level Voltage 4.5V
Ambient Light Filter up to 500LUX
As a signal transmitter, I used the Elegoo IR Remote Control with 21 buttons. This remote control emits an coded signal through an infrared LED light. This signal is modulated at a frequency of 38kHz, allowing it to be detected by the KY-022. Each button on the remote control sends a different encoded signal, enabling the assignment of a specific function to each button during programming. This infrared light signal is differentiated between buttons by the duration and sequence of pulses of light modulated at 38 kHz, and each of these signals is assigned a code that identifies the button.
Programming and Testing
To start, I used the program provided in the sensor datasheet. This program allows checking the sensor's operation and, at the same time, enables viewing the code that identifies each button of the transmitter. I used the Arduino IDE for programming, and the code is as follows:
Finally, I programmed the sensor using two buttons of the remote control so that it allows me to move the servo motor 180 degrees to the right and then back to 0 degrees with the other button. I did this with the help of ChatGPT, and the result was as:
Group Assignment
Downloads