11. Input devices¶
Assignement¶
INPUT DEVICES @ OUTPUT DEVICE COMBINATION to make assignment easly
assignment I add a sensor to a microcontroller board that I have designed and adding the output devices . adding an input and read the data of that input device. I removed the push button and replaced it with HC-SR04 ultrasonic distance sensor in 2cm to 400cm as output i add LCD .
HC-SR04 SENSOR sends trigger signal and receive echo signal. In my design , the trigger signal is set HIGH (high voltage) for 200 ms and set LOW (low voltage) for 10 ms.At the end of the trigger signal high, echo signal will be received in the form of high voltage, followed with a delay for 10 ms and then followed with 10ms delay where all the signals be at low voltage.
After desinging I generated SVG file which I converted to PNG through Gimp.
Printing the Board¶
I first setted the origin cordinates for my board and used the RML file .I generated to print and cut my circuit. After printing the board I soldered all the component on the board.
I used this program to sense the distance from sensor and object.
#include <LiquidCrystal.h>
#define trigger 18
#define echo 19
LiquidCrystal lcd(2,3,4,5,6,7);
float time=0,distance=0;
{
lcd.begin(16,2);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
lcd.print(" Ultra sonic");
lcd.setCursor(0,1);
lcd.print("Distance Meter");
delay(2000);
lcd.clear();
lcd.print(" Circuit Digest");
delay(2000);
}
void loop()
{
lcd.clear();
digitalWrite(trigger,LOW);
delayMicroseconds(2);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
delayMicroseconds(2);
time=pulseIn(echo,HIGH);
distance=time*340/20000;
lcd.clear();
lcd.print("Distance:");
lcd.print(distance);
lcd.print("cm");
lcd.setCursor(0,1);
lcd.print("Distance:");
lcd.print(distance/100);
lcd.print("10mm");
delay(1000);
}
This video show my test using HC-SR04 sensor and output using LCD