Programmable Logic

Enter Your Electronics & Design Project for a chance to win up to a $200 Shopping Cart of Product!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll

 

SMART CYCLE

 

 

SUMMARY

 

In today’s world everything is being revolutionised and technological advancements are made everyday to day objects smarter so why not our cycles?
Cyclists and motorists are the most likely to be killed or injured on the road as fatality rates are higher due to lesser protection and slow timing of emergency services as, cyclists and motorists are likely to get flung into the air and at a distance away from the crash site or into the vegetation(if any present) around the crash site. About 102 cyclists were killed on British roads in 2016. Around 3,400 were seriously injured, and there were approximately about 15,000 other casualties.So to change this our goal was not only focused on making cycles smarter but also in making it more safer for the rider in many various ways.With some simple microcontroller Arduino and some code and succeeded in making cycles not only smarter but also safer.
We know that cycling is gaining popularity due to climate change and also to prevent global warming by using an alternative cost effective and eco-friendly method ,but at the same time accident rates related to it are also increasing due to reckless riding of both a vehicle driver and also a cycle rider in some minor cases as when the road are slippery due to a wet tarmac or because of unexpected rain. In the five years between 2011 and 2015, about 25,435 cyclists have been killed in India. Despite all the positive things about cycling, today it is one of the most dangerous modes of transportation in India ,and has put riders to great risk. In our country (India) cycling has become dangerous but with innovation such as ours and better implementation of road safety and laws regarding motorised vehicles the risk can be significantly reduced. But still even though all of us have experienced such gruesome events or witnessed them. For example I know a person who was involved in an hit and run incident, the person received minor injuries but only because the driver was not driving st a high speed. This could have been much worse if the driver was driving fast. So to see a change and to help cyclists around the globe we have made a cycle which has the following feature :
We have made fall detection, brake light, anti-theft detection , attention alert(based on speed and distance of the rider and surrounding vehicles) as well as an ability to access the location of the cycle via the Internet all in one circuit. It has become smarter by having built in speedometer and odometer and showing the weather features such as temperature,wind speed,humidity and also time.
Fall detection is made using accelerometer and will detect fall of cycle when it is in motion and will immediately send a message to specified contacts and/or emergency services.This will help the loved ones to know if the cyclists has met with an accident.This helps to take immediate action.The fall detection will reduce the risk of the the injury manifesting into something that may lead to further complications and possibly even death of the rider.
Brake lights will alert the vehicles behind the cycle that the cycle is slowing down.
R.F.I.D. will be used as a lock. It will be embedded into the helmet so that only the rider who has the helmet is the only person who is able to unlock the cycle. Without which if the lock is being forcibly opened a buzzer will make pound noises to attract the attention of anyone nearby, also alerting the rider and this will force the thief to run away or risk getting caught, for many people a cycle is their only mode of transportation. I for one commute on my cycle too and have narrowly avoided such incidents but have suffered from a few as well I have friends who have been injured just as well due to reckless driving of others. At one point of time cycling was awesome as you rode with your friends with the wind blowing in your hair, without a care in the world but now it’s very dangerous. Sometimes you just miss the old times and want to bring those memories back for others to experience.

                                                                                                                                                            HARDWARE REQUIRED

The following hardware is used to make the project

  • Arduino MKR VIDOR 4000
  • Arduino Nano
  • MFRC552 Rfid Module
  • Pir Motion Sensor
  • ADXL335 Accelerometer
  • HC-SR-04 Ultrasonic Sensor
  • IR Transmitter and Receiver
  • Switch
  • LED
  • Buzzer

                                                                                                                                                            SOFTWARE REQUIRED

The following software is used to make the project

  • Arduino IDE
  • Blynk
  • IFTTT
  • Webhooks

                                                                                                                                                                      WORKING                                                       

The project works in following manner

  • The Helmet is having the rfid(Radio Frequency Identification) card embedded on it thus whenever the helmet is shown arduino nano is coded to identify that card as the key and give this data to arduino mkr vidor, thus displaying status of  lock on the screen
  • The ir transmitter is to be fit on the spoke of the wheel and the ir receiver in such a way that it comes in line of ir transmitter one time during one rotation , thus when wheel completes one rotation the arduino takes this data to calculate the distance (circumference * no of rotation) and difference between two rotation is taken to calculate instantaneous speed by(circumference / time difference).
  • The accelerometer gives the tilt of the device by giving x , y , z axis values as analog values.Thus by finding the values at different tilt the conditions of cycle fall can be detected and used to give the data to esp32 and it would then send data to ifttt via blynk which will then send sms.
  • The ultrasonic sensor would detect the safe distance for ringing the buzzer and get attention of rider by doing (constant*speed<=distance)
  • The Pir motion sensor detects the ir rays emitted by humans and detects their motion and thus give data to Arduino.Thus finding the presence of any person.
  • the Esp32 would be connected to blynk, and ifttt and also receive data from the arduino and act as bridge for connecting arduino to internet.
  • The Switch would be placed in such a way between handle and brake that led turns on when brake is pressed.

Code for ESP32

In this project the MKR Vidor displays the data over screen and also shows rear view using when button is pressed.

#include "VidorGraphics.h"
#include "VidorCamera.h"

const int trigPin = 9;
const int echoPin = 10;
const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;   
long duration;
int distance2;


//obstacle and buzzer and horn based on speed
#include <Wire.h> //Include Wire library
#include "Vidor_GFX.h"
#include "VidorGraphics.h"
#include "VidorCamera.h"
VidorCamera vcam;
void setup() {
  // initialize the serial communications:
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input


  pinMode(53, INPUT);
  pinMode(15, OUTPUT);
  pinMode(16, INPUT);
  //pinMode(12, INPUT);
  pinMode(17, OUTPUT);
  pinMode(A5, OUTPUT);
  pinMode(A4, OUTPUT);
  digitalWrite(A4, LOW);
  digitalWrite(A5, HIGH);


  pinMode(51, OUTPUT);


  pinMode(13, OUTPUT);
  pinMode(49, OUTPUT);
  digitalWrite(49, HIGH);
  digitalWrite(17, HIGH);
  digitalWrite(51, LOW);
  digitalWrite(15, LOW);
if (!FPGA.begin()) {
    Serial.println("Initialization failed!");
    while (1) {}
  }

}



int c=0;
int b = 0;
int count = 0;
int count3 = 0 ;
int num = 0;
int d=0;
int e = 0;
double timer = 0;
double circumference = 2.2;
double speed_cycle;
void loop() {


digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance2= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance2);
int aabhas = digitalRead(53);
  Serial.println(aabhas);
  if (aabhas == 1)
  { //count2++;
    num = count3;
  }


  if (digitalRead(12) == HIGH)
  { Serial.println("lock open");
    vdgfx.text.setCursor(15, 260);
  vdgfx.print("Lock Access-");
  vdgfx.print("open");
  }


  if (digitalRead(12) == LOW)
  {
    Serial.println("lock close");
    vdgfx.text.setCursor(15, 260);
  vdgfx.print("Lock Access-");
  vdgfx.print("close");
  }
  if (digitalRead(16) == HIGH)
  {
    digitalWrite(13, HIGH);
  }
  if (digitalRead(16) == LOW)
  {
    digitalWrite(13, LOW);
  }
  if ((aabhas == 0) && (count3 == num + 1)  )
  {
   // timer = millis()/1000 - b;
 c=millis();
timer = c-b;
    b=c;
    count++;


    //count2 = 0;
  }
  int distance = (circumference) * count;

     
  if(count/2==0) {
     
    d = millis();
    }
   if((count/2) ==1)
    {
      e=millis();
      }

  Serial.println(speed_cycle);
  Serial.println(millis() / 1000);

  
  
  Serial.println(distance);
  Serial.println(analogRead(xpin));
Serial.println(analogRead(ypin));
Serial.println(analogRead(zpin));
 vdgfx.fillRect(0, 0, 640, 480, vdgfx.Yellow ());


  vdgfx.text.setColor(vdgfx.Green());
  vdgfx.text.setAlpha(187);
  vdgfx.text.setSize(2);
  vdgfx.text.setCursor(15, 40);
  vdgfx.print("Smart Cycle");
  
 vdgfx.text.setColor(vdgfx.Blue());
  vdgfx.text.setAlpha(255);
  vdgfx.text.setSize(1);
  vdgfx.text.setCursor(15, 140);
  vdgfx.print("Speed: ");
  vdgfx.print(speed_cycle); vdgfx.print("m/s");


  vdgfx.text.setCursor(15, 200);
  vdgfx.print("Distance: ");
  vdgfx.print(distance); vdgfx.print("m");



    vdgfx.text.setColor(vdgfx.Blue());
  vdgfx.text.setAlpha(120);
  vdgfx.text.setSize(1);
  vdgfx.text.setCursor(15, 400);
  vdgfx.print("By:Aabhas");


if (digitalRead(1)==HIGH) {
   vcam.begin();
   delay(30000);
  }
  vcam.end();
  
  
  count3++;
}

 

CONCLUSION AND FINAL PRODUCT

 

 

 

 

 

 

 

 

This project was earlier made using Arduino mega connected with arduino nano for rfid  and esp32 for wifi connection but now i have made this project using mkr vidor 4000 board and arduino nano for rfid , i have not made video , i will make and upload it soon .

I also tried out mkr vidor qr recognition code and i have made its video as well(the video is not good please bear with it).

Link to video - https://photos.app.goo.gl/bX2kUeZ7NAYWF7bc8 .

 


MADE BY AABHAS SENAPATI