// 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
Comments