Introduction: Motoalert

It’s a arduino project prototype, focus on motorbike riders. This product advise with lights to the people that is not respecting the "law of distancie with the vehicles" on you when you ride. If the car is getting closer than beetwen 3m or 1,5m, the red leds of the helmet gets on, and if they go less than 1,5m change to orange leds. This leds are used for warning other cars and prevent an accident.

Step 1: The Problem That Worries Us

Nowadays, in traffic accidents, the highest percentage is due to a motorcycle accident. Cars never respect safety distances, hence there are collisions from behind. With motoalert the cars will be warned if they get too close to your bike, and that can avoid many accidents of people driving clumsily.

Step 2: Write the Code

#define trigPin 13
#define echoPin 12

#define led 11

#define led2 10

void setup() {

Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(led, OUTPUT);

pinMode(led2, OUTPUT); }

void loop() {

long duration, distance;

digitalWrite(trigPin, LOW);


digitalWrite(trigPin, HIGH);

// delayMicroseconds(1000);


digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration / 2) / 29.1;

if (distance >= 150 && distance < 300) {

digitalWrite(led, HIGH);

digitalWrite(led2, LOW);


else if (distance >= 0 && distance < 150) {

digitalWrite(led, LOW);

digitalWrite(led2, HIGH);


else {

digitalWrite(led, LOW);

digitalWrite(led2, LOW);


if (distance >= 300 || distance <= 0) {

Serial.println("Out of range");


else {


Serial.println(" cm");


delay(500); }

Step 3: Material for Electronic Sensor Part

We need:

- 5 red leds

- 5 orange leds

- 2 resistors of 56 ohms

- 2 resistors of 220 ohms

- 2 Transistors bjt npn

- Arduino uno

- Ultrasonic sensor HC-SR04

- Cables

Step 4: Weld Leds Base and Made Circuit

For not use one pin for each led, we use 1 transistor bjt npn, for active all leds of the line. We conect all leds to resistence for limit current and protect leds and transistors.

Step 5: Prove the Circuit

We made all circuit and connected to the computer and we it works good!

Step 6: Build the Prototype

Using a helmet carcase, we installed the sensor, leds base and the arduino. For not connect arduino to the computer, we put a 9v battery source.

Step 7: Let's Drive Now Safety!

Arduino Contest 2017

Participated in the
Arduino Contest 2017

LED Contest 2017

Participated in the
LED Contest 2017