Control an LED based on the range detected by an ultrasonic sensor

// Define pinsconst int trigPin = 9; // Trigger pin of the ultrasonic sensorconst int echoPin = 10; // Echo pin of the ultrasonic sensorconst int ledPin = 13; // LED pin void setup() {pinMode(trigPin, OUTPUT); // Set trigPin as outputpinMode(echoPin, INPUT); // Set echoPin as inputpinMode(ledPin, OUTPUT); // Set LED pin as outputSerial.begin(9600); // … Continue reading Control an LED based on the range detected by an ultrasonic sensor