AJ-SR04M Waterproof ultrasonic sensor testing TrigEco Mode-1 and UART Communication mode-4 code
Full video- https://youtu.be/Wsxv97HIU-c?si=3Wx6_a_YFcpJnHO7 UART communication short- https://youtube.com/shorts/uVVg_NuV92s?si=c0VhZxT8jl2V60o6 1. TrigEco mode-1 code- >>TrigEco mode-1 Minimal code- #define ECHOPIN 5 #define TRIGPIN 18 void setup () { Serial . begin ( 115200 ) ; pinMode ( ECHOPIN, INPUT ) ; // Fixed: Standard input without pull-up pinMode ( TRIGPIN, OUTPUT ) ; } void loop () { digitalWrite ( TRIGPIN, LOW ) ; delayMicroseconds ( 2 ) ; digitalWrite ( TRIGPIN, HIGH ) ; delayMicroseconds ( 10 ) ; // Fixed: Standard 10µs trigger pulse digitalWrite ( TRIGPIN, LOW ) ; // 30,000 µs (30ms) timeout allows measurement up to ~5 meters long duration = pulseIn ( ECHOPIN, HIGH, 50000 ) ; int distance = duration / 58 ; Serial . print ( distance ) ; Serial . println ( " cm" ) ; delay ( 50 ) ; } >>TrigEco mode-1...