Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 사물인터넷
- 코딩테스트
- 개인프로젝트
- 빅데이터
- 코스닥
- 주가예측
- 코딩독학
- SNS
- 자바독학
- 코테
- 풀스택프레임워크
- 개발
- 이웃한 칸
- Python
- 모의 주식
- 프로그래머스
- java
- 프로그램
- backend
- java정리
- 프로그래밍
- C++
- 코딩
- 자바
- Project
- Reflex
- frontend
- 자바정리
- 개발자
- 백준
Archives
- Today
- Total
Creative Code
10_ultrasonic(초음파 거리재기) 본문
const int trig_pin =11;
const int echo_pin =12;
void setup() {
// put your setup code here, to run once:
pinMode(trig_pin,OUTPUT);
pinMode(echo_pin,INPUT);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trig_pin,LOW);
delayMicroseconds(2);
digitalWrite(trig_pin,HIGH);
delayMicroseconds(10);
digitalWrite(trig_pin,LOW);
long duration = pulseIn(echo_pin,HIGH);
long distance = (duration/2)/29.1;
Serial.print(distance);
Serial.println( "cm");
delay(300);
}
'Arduino(C,C++)' 카테고리의 다른 글
12_timer1_piezo (0) | 2023.08.14 |
---|---|
11_timer1_led (0) | 2023.08.14 |
09_tone (0) | 2023.08.11 |
08_joystick (0) | 2023.08.11 |
07_Analog_Read-(2) 조명센서밝기에 따른 led밝기 조절 (0) | 2023.08.11 |