ULTRASONIC SENSOR PROJECT
the pin connection is here
the library download link is here
http://j.gs/74qv
if we connect to the led in pin 8
we can swich the led with any distance for your like
the code is follow
#include <Ultrasonic.h>
#define ledPin 8
#define TRIGGER_PIN 12
#define ECHO_PIN 11
Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
float cmMsec, inMsec;
long microsec = ultrasonic.timing();
cmMsec = ultrasonic.convert(microsec, Ultrasonic::CM);
inMsec = ultrasonic.convert(microsec, Ultrasonic::IN);
Serial.print("MS: ");
Serial.print(microsec);
Serial.print(", CM: ");
Serial.print(cmMsec);
Serial.print(", IN: ");
Serial.println(inMsec);
if(cmMsec< 20){
digitalWrite(8, HIGH); }
else{ digitalWrite(8, LOW);}}
if we have any problem please email,
wathu.eshan@gmail.com
- ARDUINO
- arduino-tempertuer-controller
- how to burnbootloarder and power circuit
- Visual- development-tool\for\Arduino
- Arduino sonar system
- arduino\ toilet-flusher
- arduino-ir remote\controller
- simple arduino\line\following\robot\with\LDR
- arduino keypad\password controller
- arduino\for proteus
- Arduino-ldr-controller
- Arduino-ultrasonic-sensor
- ELECTRONIC
- ELECTIRCAL
- MECHATRONICS
- solidworks
Saturday, December 12, 2015
Subscribe to:
Post Comments (Atom)
Nice job...
ReplyDelete