Rays2020
Published © GPL3+

Timing device (English Version)

To enforce physical distancing

BeginnerShowcase (no instructions)186
Timing device (English Version)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Cable schematics

Code

Untitled file

Arduino
// created by Rays


#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

float EtatBouton = 0;
float Flux = 0;
float fluxseconde = 0;
float d_C3_A9part = 0;

float getDistance(int trig,int echo){
    pinMode(trig,OUTPUT);
    digitalWrite(trig,LOW);
    delayMicroseconds(2);
    digitalWrite(trig,HIGH);
    delayMicroseconds(10);
    digitalWrite(trig,LOW);
    pinMode(echo, INPUT);
    return pulseIn(echo,HIGH,30000)/58.0;
}

void _delay(float seconds) {
  long endTime = millis() + seconds * 1000;
  while(millis() < endTime) _loop();
}

void setup() {
  pinMode(8,OUTPUT);//démarrage
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  digitalWrite(8,1);
  _delay(0.5);
  digitalWrite(8,0);
  digitalWrite(5,1);
  while(!(d_C3_A9part == 1.000000))
  {
    _loop();
    if(10 > getDistance(2,3)){//voir tout en bas pour infos
        digitalWrite(8,1);
        _delay(0.5);
        digitalWrite(8,0);
        _delay(0.5);
        digitalWrite(8,1);
        _delay(0.5);
        digitalWrite(8,0);
        d_C3_A9part = 1;
        digitalWrite(6,1);
        digitalWrite(5,0);

    }

  }

}

void _loop() {
}

void loop() {
  if(10 > getDistance(2,3)){
      digitalWrite(6,0);
      digitalWrite(5,1);
      _delay(3);//temps d'attente entre chaque personnes
      digitalWrite(6,1);
      digitalWrite(5,0);
      digitalWrite(8,1);
      _delay(0.25);
      digitalWrite(8,0);

  }

  _loop();
}
// pour que le dispositif fonctionne, il faut passer sa main devant la capteurs à ultrasons

Credits

Rays2020

Rays2020

0 projects • 0 followers

Comments