#include <value.h>
#include <My_Arduino_GPIO_Lib_V1_8.h>
#include <TM1637Display.h>
// TM1637
#define CLK 8
#define DIO 9
//sr04
#define echo 6
#define trg 5
TM1637Display seg(CLK, DIO);
void setup() {
// put your setup code here, to run once:
//1. TM1637 init
pinMode(CLK, OUTPUT);
pinMode(DIO, OUTPUT);
//2. 초음파센서 init
pinMode(trg, OUTPUT);
pinMode(echo, INPUT);
//3. Uart Init
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
d_out(trg, 1);
delayMicroseconds(10); // 10uS
d_out(trg, 0);
long distance = pulseIn(echo, 1) / 58;
Serial.print(distance, DEC);
Serial.println("cm");
_delay_ms(500);
}
첨부파일첨부된 파일이 1개 있습니다.
다음검색