Project showcase
Blind Runner Alarm: Speed Measuring Device

Blind Runner Alarm: Speed Measuring Device © LGPL

A device to prevent students running fast.

  • 3,736 views
  • 2 comments
  • 5 respects

Components and supplies

About this project

We witnessed children running and hurt in the corridor in front of the school cafeteria and making loud noises.

We created 'The Speed Measuring Device' to prevent such accidents.

Code

project.inoC/C++
#include <Servo.h>

#define BUZZ 2
#define T1 3
#define T2 4
#define E1 5
#define E2 6
#define servoPin 9
#define LED 13

Servo servo;

float wall1, wall2;
int school = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(BUZZ, OUTPUT);
  pinMode(T1, OUTPUT);
  pinMode(T2, OUTPUT);
  pinMode(E1, INPUT);
  pinMode(E2, INPUT);
  pinMode(LED, OUTPUT);
  servo.attach(servoPin);
  get_dis(T1, E1);get_dis(T2, E2);get_dis(T1, E1);get_dis(T2, E2);
  get_dis(T1, E1);get_dis(T2, E2);get_dis(T1, E1);get_dis(T2, E2);
  Serial.println(wall1 = get_dis(T1, E1));
  Serial.println(wall2 = get_dis(T2, E2));
}

void loop()
{
  bool B = false;
  long Time = 0;
  while (1)
  {
    if (check_super(T1, E1, wall1) == 1)
      { B = true; Time = millis(); break; }
    else if (check_super(T2, E2, wall2) == 1)
      { B = false; Time = millis(); break; }
    if (check_super(T1, E1, wall1) == 2)
      { return; }
    else if (check_super(T2, E2, wall2) == 2)
      { return; }
  }
  delay(50);
  if (B)
    while (1)
    {
      if (check_super(T2, E2, wall2) == 1)
      {
        Time = millis() - Time;
        break;
      }
      else if (millis() - Time > 1000)
        break;
    if (check_super(T1, E1, wall1) == 2)
      { return; }
    }
  else
    while (1)
    {
      if (check_super(T1, E1, wall1) == 1)
      {
        Time = millis() - Time;
        break;
      }
      else if (millis() - Time > 1000)
        break;
    else if (check_super(T2, E2, wall2) == 2)
      { return; }
    }
  if (Time < 300)
  {
    BUZZER(2000);
    digitalWrite(LED, LOW);
  }
  delay(1000);
}

int check_super(int tri, int echo, float wall)
{
  delay(10);
  float F = get_dis(tri, echo);
  Serial.println(F);
  int B = ((wall * (float)4) / (float)5 > F) ? 1 : 0;
  B = (F > (float)1000) ? 2 : B;
  delay(10);
  return B;
}

float get_dis(int tri, int echo)
{  
  digitalWrite(tri, HIGH);
  delayMicroseconds(15);
  digitalWrite(tri, LOW);
  delayMicroseconds(10);
  float dis = 0.017 * pulseIn(echo, HIGH);
  return dis;
}

void BUZZER(int T)
{
  long Time = T + millis();
  int delayed_T = 0, LED_state = HIGH;
  while(1)
  {
    digitalWrite(BUZZ, HIGH);
    delay(1);
    digitalWrite(BUZZ, LOW);
    delay(1);
    if (millis() > Time)
      break;
    delayed_T += 2;
    if (delayed_T > 100)
    {
      digitalWrite(LED, LED_state);
      LED_state = (LED_state == HIGH) ? LOW : HIGH;
      delayed_T = 0;
    }
  }
}

Schematics

diagram
untitled_sketch_PWtfHIQm15.fzz
diagram
  yhewhojngm

Comments

Similar projects you might like

Arduino Blind Stick

Project tutorial by hadi1234

  • 27,290 views
  • 10 comments
  • 27 respects

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 32,570 views
  • 11 comments
  • 32 respects

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 93,976 views
  • 14 comments
  • 51 respects

Ultrasonic Glasses for the Blind

Project tutorial by Team GardnerTech

  • 51,091 views
  • 37 comments
  • 127 respects

Sensal - All Senses Alarm Clock

Project in progress by Leonid Piliptsevich

  • 15,508 views
  • 2 comments
  • 31 respects

Portable Range Detection Device

Project tutorial by Viktor S

  • 12,635 views
  • 6 comments
  • 26 respects
Add projectSign up / Login