/* Lycée PE MARTIN
Le 2/11/2023
Titre : LED5corr (Pull-Up)
Matériels : Arduino Uno, Led RGB, 3 switchs
Description : accès à un Parking décrit dans le sujet du TP GPIO
Lien : https://webge.fr/tsin.php#
*/

// Entrées, sorties
#define LEDR 12 // Feu s'éclaire en rouge
#define LEDV 8  // Feu s'éclaire en vert
#define G 4     // Parking plein
#define H 3     // Hauteur véhicule > 2m
#define P 2     // Présence véhicule

void setup() {
  // Configuration des E/S
  pinMode(LEDR, OUTPUT);
  pinMode(LEDV, OUTPUT);
  pinMode(G, INPUT_PULLUP);
  pinMode(H, INPUT_PULLUP);
  pinMode(P, INPUT_PULLUP);
}

void loop() {
  // Lecture des entrées
  bool g = !(digitalRead(G));
  bool h = !(digitalRead(H));
  bool p = !(digitalRead(P));
  
  // Traitement
  bool ledR = !(!g && !h && p);
  bool ledV = !g && !h && p;
 
  // Ecriture sur les sorties
  digitalWrite(LEDR,ledR);
  digitalWrite(LEDV,ledV);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
vcc1:VCC
gnd1:GND
gnd3:GND
gnd4:GND
sw1:1
sw1:2
sw1:3
sw2:1
sw2:2
sw2:3
rgb1:R
rgb1:COM
rgb1:G
rgb1:B
sw3:1
sw3:2
sw3:3
gnd2:GND
gnd5:GND
r1:1
r1:2
r2:1
r2:2
G
H
P
LED_RGB
R1
R2
1
0
12
8
4
3
2
220
220
rouge
vert
<< Accès de Parking >>
P : Simulation capteur présence véhicule
H : Simulation capteur hauteur véhicule > 2m
G : Simulation contact parking plein
LED_RGB : Simulation du feu bicolore
VERT : ouverture barrière - ROUGE : barrière fermée