Input Devices
Week assignments
In this assignment I have to:
* Probe an input device's analog levels and digital signals
* measure something: add a sensor to a microcontroller board that I have designed and read it.
Input Devices:
Input devices is a device used to provide data and signals to a microcontroller. This devices called sensors, which responds to a physical stimulus (such as heat, light or sound) and transmits to an electrical signal.
In this assignment I have test Solu Water Level Sensor as shown below:
Water Sensor water level sensor is an easy-to-use, cost-effective high level/drop recognition sensor, which is obtained by having a series of parallel wires exposed traces measured droplets/water volume in order to determine the water level. Easy to complete water to analog signal conversion and output analog values can be directly read Arduino development board to achieve the level alarm effect.
This sensor has tree pins, one for 5 volt, one for ground and the third for signal.
Specifications:
1. Product Name: water level sensor.
2. Operating voltage: DC3-5V.
3. Operating current: less than 20mA.
4. Sensor Type: Analog.
5. Detection Area: 40mmx16mm.
6. Production process: FR4 double-sided HASL.
7. Operating temperature:10℃-30℃.
8. Humidity: 10% -90% non-condensing.
9. Product Dimensions: 62mmx20mmx8mm.
Programming:
I wrote a code to use the sensor as water leakage detector, a led turns on if the sensor contact with water.
I wrote the code using Arduino IDE.
The Circuit
In this assignment I used the board that I designed in "Week 7"
The code:
int pushButton = 4;
int LEDPin=0;
int buttonState;
void setup() {
pinMode(pushButton, INPUT);
pinMode(LEDPin,OUTPUT);
digitalWrite(LEDPin,HIGH);
delay(500);
digitalWrite(LEDPin,LOW);
delay(500);
}
void loop() {
buttonState = digitalRead(pushButton);
if (buttonState==1)
{digitalWrite(LEDPin,HIGH); }
else{digitalWrite(LEDPin,LOW);}
}
Now, I tested the sensor as in the video: