0% found this document useful (0 votes)
6 views5 pages

ALI Arduino

The document contains an Arduino program that controls a set of LEDs and buttons to simulate an elevator system. It defines various pins for buttons and LEDs, and includes logic to read button states and update the current floor of the elevator accordingly. The program uses loops and conditions to manage the elevator's movement and LED indicators based on user input.

Uploaded by

TOURE ALI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

ALI Arduino

The document contains an Arduino program that controls a set of LEDs and buttons to simulate an elevator system. It defines various pins for buttons and LEDs, and includes logic to read button states and update the current floor of the elevator accordingly. The program uses loops and conditions to manage the elevator's movement and LED indicators based on user input.

Uploaded by

TOURE ALI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

#define B 7

#define C 6

#define D 5

#define E 4

#define F 3

#define G 2

#define BUTTON 12

byte v = 0;

void setup() {

pinMode(A, OUTPUT);

pinMode(B, OUTPUT);

pinMode(C, OUTPUT);

pinMode(D, OUTPUT);

pinMode(E, OUTPUT);

pinMode(F, OUTPUT);

pinMode(G, OUTPUT);

pinMode(BUTTON, INPUT);

void loop() {

digitalWrite(A, HIGH);

digitalWrite(B, HIGH);

digitalWrite(C, HIGH);

digitalWrite(D, HIGH);

digitalWrite(E, HIGH);

digitalWrite(F, HIGH);
digitalWrite(G, LOW);

delay(500);

if (digitalRead(BUTTON) == HIGH) { v = 1; }

while (v == 1) {

digitalWrite(A, LOW);

digitalWrite(B, HIGH);

digitalWrite(C, HIGH);

digitalWrite(D, LOW);

digitalWrite(E, LOW);

digitalWrite(F, LOW);

digitalWrite(G, LOW);

delay(500);

if (digitalRead(BUTTON) == HIGH) { v = 2; }

while (v == 2) {

digitalWrite(A, HIGH);

digitalWrite(B, HIGH);

digitalWrite(C, LOW);

digitalWrite(D, HIGH);

digitalWrite(E, HIGH);

digitalWrite(F, LOW);

digitalWrite(G, HIGH);

delay(500);

if (digitalRead(BUTTON) == HIGH) { v = 3; }

}
while (v == 3) {

digitalWrite(A, HIGH);

digitalWrite(B, HIGH);

digitalWrite(C, HIGH);

digitalWrite(D, HIGH);

digitalWrite(E, LOW);

digitalWrite(F, LOW);

digitalWrite(G, HIGH);

delay(500);

if (digitalRead(BUTTON) == HIGH) { v = 4; }

// Déclaration des boutons

const int BP0 = 2;

const int BP1 = 3;

const int BP2 = 4;

// Déclaration des LED étages

const int LED0 = 8;

const int LED1 = 9;

const int LED2 = 10;

// LED direction

const int LED_UP = 11;

const int LED_DOWN = 12;


int etageActuel = 0;

int etageDemande = 0;

void setup() {

pinMode(BP0, INPUT);

pinMode(BP1, INPUT);

pinMode(BP2, INPUT);

pinMode(LED0, OUTPUT);

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED_UP, OUTPUT);

pinMode(LED_DOWN, OUTPUT);

digitalWrite(LED0, HIGH); // départ au RDC

void loop() {

// Lecture des boutons

if (digitalRead(BP0) == HIGH) etageDemande = 0;

if (digitalRead(BP1) == HIGH) etageDemande = 1;

if (digitalRead(BP2) == HIGH) etageDemande = 2;

// Comparaison des étages

if (etageDemande > etageActuel) {

digitalWrite(LED_UP, HIGH);
digitalWrite(LED_DOWN, LOW);

delay(2000); // temps de montée

etageActuel++;

else if (etageDemande < etageActuel) {

digitalWrite(LED_DOWN, HIGH);

digitalWrite(LED_UP, LOW);

delay(2000); // temps de descente

etageActuel--;

else {

digitalWrite(LED_UP, LOW);

digitalWrite(LED_DOWN, LOW);

// Mise à jour des LED d’étage

digitalWrite(LED0, etageActuel == 0);

digitalWrite(LED1, etageActuel == 1);

digitalWrite(LED2, etageActuel == 2);

You might also like