Input Devices
This week, I will be using some new sensors for input.
1.1 Assignments of the Week
- Group assignment:
1.Probe an input device(s)'s analog levels and digital signals.
2.Document your work on the group work page and reflect on your individual page what you learned.
- Individual assignment:
1.Measure something: add a sensor to a microcontroller board that you have designed and read it.
1.2 Group Work
1.3 Individual Work
1.3.1 ultrasonic sensor
The ultrasonic sensor is a type of sensor that measures distance using the principle of ultrasonic waves. It calculates the distance to an object by emitting ultrasonic pulses and receiving their echoes. This sensor typically consists of a transmitter and a receiver and can accurately measure the distance to a target object without physical contact.
Wiring:
Coding:
I used ChatGPT to obtain sample code and made modifications for measuring ultrasonic distance and controlling a small light. The code uses the pulseIn() function to read the duration of the high pulse on the Echo pin and converts it to distance in centimeters. If the measured distance is less than or equal to 5 centimeters, it turns on the LED; otherwise, it turns off the LED.
Ultrasonic_ranging_lighting:
Video:
1.3.2 touch sensor
The capacitive touch switch module is a module that utilizes capacitive sensing principles to detect touch, commonly used for proximity sensing or switch control applications. This module can sense human proximity or touch to trigger corresponding actions or controls.
Its operation is similar to a capacitive sensor, detecting changes in capacitance in the surrounding environment to achieve touch detection. When an object (typically a human finger) approaches or touches the module, it alters the capacitive sensing state, which is then detected by the module.
Wiring:
Coding:
This program continuously reads the analog input value from a touch sensor and outputs it through the serial port.
touch_communication:
Video: