PinMode(led, OUTPUT) //Define LED pin as output PinMode(echoPin, INPUT) //Define Echo pin as input PinMode(trigPin, OUTPUT) //Define Trigger pin as output Serial.begin (9600) //Begin serial monitor with baud rate 9600
#define led 12 //Initialize pin12 for LED #define echoPin 8 // Initialize pin8 for HC-SR04 Echo
The following table shows the connections you need to make: Components Requiredīefore diving into the details, let’s list the components required for this project: Let’s get started with Ultrasonic Sensor Library for Proteus, Ultrasonic Sensor Library for Proteus using which you can easily simulate this Ultrasonic sensor in Proteus and can also interface it with Arduino boards.
Ultrasonic sensor normally used is HC-SR04, which is also used here in this library.