Overview
Input devices are devices that take in input/information send it to a microcontroller so it can process it and make decisions. There are different types of input devices that detect different things (ex: touch, temperature, distance, etc).
Input devices either give Analog (range of values) or Digital (1 or 0) signals.
Touch Sensor
I connected a touch sensor to the pcb i made in Week 8
Here is the touch sensor:
What to connect where:
SIG -> GPIO6 (purple wire)
VCC -> 3V3 (red wire)
GND -> GND (black wire)
Blink code:
|
|
Explanation of the Code:
- setup() function runs once when the Arduino powers on.
- pinMode(6, INPUT) -> Sets pin 6 as an input. This is where we read signals from (ex. a button).
- pinMode(2, OUTPUT) -> Sets pin 2 as an output. This is where we send signals to (ex., turning on an LED or motor)
- digitalWrite(2, LOW) -> Initializes the output on pin 2 to LOW (off) at the start.
- The loop() function runs continuously.
- The if statement reads state of pin6 and if it is high (sensor touched) it sets pin 2 to HIGH (turns LED on)
- Otherwise (if pin 6 is LOW), the output is turned off.
Video:
Group Assignment
Here is our group assignment link