Project in progress
Smart Road

Smart Road

A model road with lights that only work when there is a car on the road. It also sounds an alarm when the car drifts out of the lane.

  • 3,182 views
  • 2 comments
  • 7 respects

Components and supplies

About this project

It is a smart city traffic system in which green, red, and yellow LEDs will be glowing alternatively.

If the car's distance from the road edge is less than 5 cm, it will sound the buzzer.

Code

Smart CITY RoadArduino
int const trigPin = 10;
int const echoPin = 9;
int const ledPin = 2;
int const Red = 12;
int const Yellow =11;
int const Green =13;
int const buzzerPin=4;
void setup()
{
digitalWrite(Green,LOW);
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
pinMode(ledpin, OUTPUT); 
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
pinMode(4,OUTPUT);
}
void loop()
{
  digitalWrite(Red,HIGH);
delay(2000);

digitalWrite(Red,LOW);
digitalWrite(Yellow,HIGH);
delay(2000);
digitalWrite(Yellow,LOW);
digitalWrite(Green,HIGH);
delay(2000);
digitalWrite(Green,LOW);
int duration, distance;

digitalWrite(trigPin, HIGH);
delay(1);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance <= 5 && distance >= 0) {

digitalWrite(ledpin, HIGH);
} 
else if(distance<=1)
{
  digitalWrite(ledpin, HIGH);
  digitalWrite(buzzpin, HIGH);
  
  }
else {
digitalWrite(ledpin, LOW);
}
Serial.print(distance);
delay(60);
}

Comments

Similar projects you might like

Smart Battery Charger Multiplexer with Smart Display

Project tutorial by leonzak

  • 3,665 views
  • 6 comments
  • 18 respects

tinyGlow Smart LEDs

by Alex Glow

  • 5,573 views
  • 3 comments
  • 27 respects

Smart Table Lamp

Project tutorial by msr048

  • 1,575 views
  • 0 comments
  • 5 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 44,687 views
  • 6 comments
  • 63 respects

Arduino Smart Lamp

Project tutorial by Arduino “having11” Guy

  • 7,727 views
  • 0 comments
  • 12 respects

Smart Blind Assistant

Project in progress by Chandru S

  • 5,145 views
  • 1 comment
  • 8 respects
Add projectSign up / Login