11. Input devices
Week asignments
1. Group assignment: probe an input device's analog levels and digital signals.
2.Individual assignment: measure something: add a sensor to a microcontroller board that you have designed and read it.
Group asignment
Check out the Puebla FabLab repository: https://fabacademy.org/2024/labs/puebla/week12/
Individual asignment
Using the same board designed in the Electronic Design assignment, I implemented a joystick to the microcontroller, it implies the use of the analog reading ports, and then logic conditions to act on certain values. For this purposes, I created the code below to read the analog values that correspond to a certain position of the joystick
PROGRAMMING WORKFLOW: To be fluent in a human or a technical language, its important to know the vocabulary (commands), and the grammatic (synthaxis). This being a fast paced course, the best way to learn is by replicating and then integrating the important chunks of code.
DIVIDE AND CONQUER: To create a successful program that knows how to read an input device, lets remember our datasheet and what is the max ammount of voltage that can go inside the analog ports (In this case 3.3 VCD cause XIAO by Seeed). The first step of the process is to create a program that can read an analog value and place it in the Arduino Serial Monitor to verify that we are actually able to watch the values fluctuating. In my case, a joystick was used due to the nature of its construction: 1 potentiometer for the X axis rotation, and 1 potentiometer for the Y axis rotation. The second part of the plan is to perform any activity after a certain analog voltage has been achieved, a comparative function like the "if" conditional might be used.
DEBUGGING: The code for step number one must contain a "Serial.print" command to read the values from the serial monitor: for beginners, it's impressive to notice that the Analog-Digital converter or ADC is turning a continuous signal into digital values ranging from 0 to 1024. If you dont know why this values, I recommend reading about counting in terms of the power of 2. The second part might be verified by displaying a specific text, or changing the state of an embedded LED. In this case, a certain LED is activated depending on the position of the joystick.