Table of Contents

Play Video

CONTINGENCY DIMUNATION

This system enhances safety on curvy mountain roads by using ultrasonic sensors to detect curves and automatically reduce vehicle speed. An I2C display shows the speed, LEDs alert the driver, and a solenoid applies the brakes to prevent accidents.

Our automatic speed control system makes driving on curvy mountain roads safer by reducing the risk of accidents. It uses ultrasonic sensors to detect curves ahead. An I2C display shows our current speed, and LEDs alert you if you’re going too fast. If needed, a solenoid connected to the brakes automatically slows down the vehicle. This system provides real-time feedback and controls your speed, helping you drive more safely on winding roads.

Components: –

  1. Arduino Board (e.g., Arduino Uno, Mega, or Nano): 1
  2. Ultrasonic Sensor (e.g., HC-SR04): 1
  3. I2C LCD Display (16×2): 1
  4. LED: 1
  5. Solenoid Valve: 1
  6. 220-ohm Resistor: 1
  7. Mini Breadboard: 1
  8. Power Supply: Batteries or USB power
  9. Wires: Male-to-male, male-to-female, and female-to-female jumper wires

Connections: –

Ultrasonic Sensor (HC-SR04):

  • VCC to Arduino 5V
  • GND to Arduino GND
  • Trig to Arduino Digital Pin 3
  • Echo to Arduino Digital Pin 2

I2C LCD Display (16×2):

  • SDA to Arduino A4 (for Uno) or dedicated SDA pin (for other boards)
  • SCL to Arduino A5 (for Uno) or dedicated SCL pin (for other boards)
  • VCC to Arduino 5V
  • GND to Arduino GND

LED:

  • Anode (+) of the LED to Arduino Digital Pin 5
  • Cathode (-) of the LED to GND through a 220-ohm resistor
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialize the I2C LCD with I2C address 0x27 and 16x2 display
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int trigPin = 3;
const int echoPin = 2;
const int ledPin = 5;

long duration;
int distance;
int speedLimit = 50;  // Example speed limit in cm per second

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(ledPin, OUTPUT);

  lcd.init();
  lcd.backlight();
  lcd.print("Speed: ");
}

void loop() {
  // Clear the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  // Set the trigPin on HIGH state for 10 microseconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);

  // Calculate the distance
  distance = duration * 0.034 / 2;

  // Calculate speed (this is a simple example, normally you would need to
  // measure the change in distance over time)
  int speed = distance;  // Placeholder for actual speed calculation

  // Display speed on LCD
  lcd.setCursor(7, 0);
  lcd.print("    ");  // Clear previous speed
  lcd.setCursor(7, 0);
  lcd.print(speed);
  lcd.print(" cm/s");

  // Check if the speed exceeds the limit
  if (speed > speedLimit) {
    digitalWrite(ledPin, HIGH);  // Turn on the LED
  } else {
    digitalWrite(ledPin, LOW);  // Turn off the LED
  }

  delay(500);  // Delay for half a second
}
Scroll to Top