Arduino UNO HC-SR04 Ultrasonik Sensör
#include <NewPing.h> #define TRIGGER_PIN 12 // Ultrasonik Sesi Gönderen Pin #define ECHO_PIN 11 // Ultrasonik Sesi Algılan Pin #define MAX_DISTANCE 200 // Max. Mesafe 200cm NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); void setup(){ Serial.begin(9600); } void loop(){ delay(50); unsigned int uS = sonar.ping(); Serial.print("Ping: "); Serial.print(uS / US_ROUNDTRIP_CM); Serial.println("cm"); }
Download Library:
https://yadi.sk/d/0m7OwWhkeSEKJ
0 yorum: