Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //******************************************
- // POP-XT with HC-SR04 Show value on GLCD
- //******************************************
- #include <popxt.h>
- #define TRIG 2
- #define ECHO 3
- void setup() {
- setTextSize(2);
- glcdMode(3);
- }
- void loop() {
- long RAW,DIST;
- out(TRIG,HIGH);
- delayMicroseconds(10);
- out(TRIG, LOW);
- RAW=pulseIn(ECHO,HIGH);
- DIST=(RAW/2)/29.1;
- glcd(0,0,"RAW=%l ",RAW);
- glcd(1,0,"DIST=%l CM ",DIST);
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement