Input Devices


Individual Assignment

This week we are tasked with measuring something: adding a sensor to a microcontroller board that we have designed and read it.



Group Assignment

Link to Group Page Our group task this week is to probe an input device's analog levels and digital signals.

This week, again we are using Kelleigh's board (me) to test the input's digital signal. Consistency is key! This week we are using the HC-SR04 ultrasonic sensor. This sensor has the ability to detect the distance between itself and an object. We will use this to generate an input that the computer reads. The HC-SR04 has 4 pinouts; the VCC, Trig, Echo, and GND. The VCC connects to the 5V pinout of my microcontroller - provides power. GND is connected to ground to create the electrical circuit loop. The Trig and Echo pins connect to any digital pin on my microcontroller. Trig pin receives the control signal from Arduino (pulse), and Echo sends a signel (pulse) to Arduino. Arduino then measures the duration of pulse to calculate distance.

To do this, we touch the black probe to the ground pin on the sensor, and the red probe to the VCC pin on the sensor. This gave us a reading for how much power is reaching the sensor. This reading was 4.98 V.

Because we do not have an oscilloscope, the testing we can do is limited.

Connections Reading

Group Assignment Part 2...

If you are looking to follow along and probe an input sensor then follow this section here, not the one above this. I was not fully knowledgable about how to measure current and resistance of a sensor before but with some help (Shoutout to Eduardo) I was able to follow a page on an LDR sensor from DIYEngineer.com and (hopefully) complete this assignment.

I will be using the microcontroller PCB that I designed and produced in house, an LDR sensor, wires, and a multimeter. The set up is quite simple but on the Fab Academy page it is said that we are not supposed to use breadboards, so my setup differs slightly from the webpage I have linked to above. The VCC pin on the LDR connected to my 5V pin, the GND went to my ground on my board, and the signal pin went on the A0 analog pin of my board.

The Arduino Code I used was actually from another website I used to help me with the group assignment, RoboIndia.com. The code was easy to read and it translated well for the outcome I desired (just reading the outputs with a multimeter). I will post the code I used below.

         // Robo India's Tutorial on LDR.
         // http://roboindia.com/


         int LDR = A0;            // LDR input at A0 pin.
         int LED = 3;             // LED is connected to PWM Pin 3.
         int LDRReading = 0;      // to store input value of LDR
         int lEDBrightness = 0;   // to store the value of LED Brightness
         int threshold_val = 800; // Check your threshold and modify it.

         void setup(){
           Serial.begin(9600);     // initializing serail communication.
           pinMode(LED, OUTPUT);   // Defining LED pin as output.
         }

         void loop(){
           LDRReading = analogRead(LDR);    // Reading LDR Input.
           Serial.println(LDRReading);      // Printing LDR input value.
           
           if (LDRReading >threshold_val){                   // Condition to make LED ON.
           lEDBrightness = map(LDRReading, 0, 1023, 0, 255); // Converting LDR to LED Brightness.
           analogWrite(LED, lEDBrightness); // Writing Brightness to LED.
           }
           else{
           analogWrite(LED, 0);             // If LDR is below threshold make LED OFF.
           }
             
           delay(300);                      // delay to make output readable on serial monitor.
         } 

From the pictures, you can see I do not have an LED or anything additional with my LDR. From reading the code, I was pretty confident it would work for the serial monitor, which is what I needed. And it did end up working just fine for me.

The table below shows the values I was given from the Arduino IDE serial monitor output, and the multimeter readings of the LDR. I probed the LDR by using the red VCC probe on the multimeter and touching it to the exposed metal section of the signal wire the LDR is connected to. The black plastic connectors have the perfect spot where the signal metal is exposed, and you can simply touch the probe to it. The ground probe on the multimeter I touched to the ground pin on my board itself, because it was the most stable place for me to keep my connection steady.

Light Condition Serial Monitor Value Multimeter Resistance
Phone Flashlight 51 0.559 MOhms
Standard Room Light 209 13.63 MOhms
Shadowed Room Light/Dark 657 24.89 MOhms

The voltage consumption was the greatest when the LDR picked up the brightest light. The increase in values from the multimeter is due to the relationship between voltage, current, and resistance. The voltage range is 0V to 5V (the max on my PCB) --> the more light the LDR reads = more voltage consumption = higher current value from the multimeter. Resistance decreases as light level increases.

Wire setup of LDR Serial monitor for LDR Shadowed LDR

This last image is the shadowed room light I am referring to in the table. Without another arm or alligator clips it is quite difficult to shade the LDR and probe at the same time.

Other Useful Sources



Individual Assignment


To start my individual assignment I needed to know which input device I wanted to work with. I didn't have much time on my hands this week so I made it something relatively easy.. a button. I opened Kicad and started designing a circuit, with the help of the resources I listed above.


Kicad


Designing in KiCad Photo Series
1 / 6
2 / 6
3 / 6
4 / 6
5 / 6
6 / 6

After adding all symbols, add wires connecting each component
Final schematic for Button circuit
Running ERC in Kicad
Updating PCB editor with all components
Started to rearrange and add my tracks
Useful pinout sheet for XIAO


Kicad


The above photos summarize my work on Kicad. To learn more about how to use Kicad to produce PCB designs, you can visit my Week 6 - Electronics Design page. A basic, simplified outline of the process is: