차승민천수민Juhyun Kim영민최
Published

발 보호 라이트

어두울 때 발을 안다치게 일정 사거리내에 들어올 시 불빛이 켜진다.

BeginnerShowcase (no instructions)1 hour41
발 보호 라이트

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×12
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
3.7 V LiPo Battery
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
우드락
커터칼

Story

Read more

Schematics

led 초음파 센서

Code

led 초음파 센서

Arduino
초음파 센서로 led의 불을 켠다.
#define TRIG_PIN 2
#define ECHO_PIN 3
#define LED_PIN 4

void setup() { 
  pinMode(TRIG_PIN, OUTPUT); 
  pinMode(ECHO_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
}
 
void loop() 
{
  int distance = 0;  
 
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10); 
  digitalWrite(TRIG_PIN, LOW); 
  distance = pulseIn(ECHO_PIN, HIGH)/58.2; /* 센치미터(cm) */
  
   /* 10cm 이내로 접근 시 LED를 켠다 */  
  if (distance <= 10) { 
    digitalWrite(LED_PIN, HIGH);
  } else {
    digitalWrite(LED_PIN, LOW);
  }
}


출처: http://gent.tistory.com/68 [젠트의 프로그래밍 세상]

Credits

차승민
1 project • 0 followers
그냥 학생입니다
천수민
1 project • 0 followers
영등포고등학교
Juhyun Kim
26 projects • 12 followers
영민최
1 project • 0 followers

Comments