Site Logo




.lnb

Ongoing Project


.content
Views 31204 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

+ - Up Down Comment Print
?

Shortcut

PrevPrev Article

NextNext Article

+ - Up Down Comment Print
Extra Form
ULR http://youtu.be/kftUaIR9PLg

I made an interesting circuit with the Ultrasonic Range Finder, LEDs, and Arduino.

The sensor responses to an object to create a distance pattern to blink LEDs.


 Range detector


http://www.amazon.com/SainSmart-HC-SR04-Ranging-Detector-Distance/dp/B004U8TOE6/ref=sr_1_1?ie=UTF8&qid=1387925482&sr=8-1&keywords=ultrasonic+range




Arduino Code


#define trigPin 3

#define echoPin 2


int led1 = 4;

int led2 = 5;

int led3 = 6;

int led4 = 7;

int led5 = 8;

int led6 = 9;

int led7 = 10;

int led8 = 11;

int led9 = 12;


void setup() {

Serial.begin(9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

pinMode(led4, OUTPUT);

pinMode(led5, OUTPUT);

pinMode(led6, OUTPUT);

pinMode(led7, OUTPUT);

pinMode(led8, OUTPUT);

pinMode(led9, OUTPUT);

}


void loop() {

long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(1);

digitalWrite(trigPin, HIGH);

delayMicroseconds(5);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;


if (distanace >=200 || distance <=0){

Serial.println("Out of Range");

}else{

Serial.print(distance);

Serial.println("cm");

}


if(distance >5){

digitalWrite(led1,HIGH);

delay(10);

}else{

digitalWrite(led1,LOW);

}


if(distance >10){

digitalWrite(led2,HIGH);

delay(10);

}else{

digitalWrite(led2,LOW);

}


if(distance >15){

digitalWrite(led3,HIGH);

delay(10);

}else{

digitalWrite(led3,LOW);

}


if(distance >20){

digitalWrite(led4,HIGH);

delay(10);

}else{

digitalWrite(led4,LOW);

if(distance >25){

digitalWrite(led5,HIGH);

delay(10);

}else{

digitalWrite(led5,LOW);

}


if(distance >30){

digitalWrite(led6,HIGH);

delay(10);

}else{

digitalWrite(led6,LOW);

}


if(distance >35){

digitalWrite(led7,HIGH);

delay(10);

}else{

digitalWrite(led7,LOW);

}


if(distance >40){

digitalWrite(led8,HIGH);

delay(10);

}else{

digitalWrite(led8,LOW);

}


if(distance >45){

digitalWrite(led9,HIGH);

delay(10);

}else{

digitalWrite(led9,LOW);

}

}





List of Articles
No. Subject Author Date Views
10 Argonaute file admin 2015.07.11 25422
9 Face casting with alginate admin 2014.02.28 31161
» LED and Distance sensor experiment admin 2013.12.25 31203
7 Experimental Game vol.2 admin 2013.12.22 31207
6 Dringking Robot admin 2013.12.12 30594
5 Experimental Game admin 2013.12.10 30590
4 Firefly Grasshopper experiment. admin 2013.11.21 31676
3 Polygon Plaster Casting admin 2013.10.22 32068
2 Firgelli Linear Actuator Test file admin 2013.10.13 35360
1 Alcohol Sensor test with Arduino file admin 2013.10.01 35096
Board Pagination ‹ Prev 1 Next ›
/ 1

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 Cancel

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5