⚲
Project
General
Profile
Sign in
Home
Projects
Help
Search
:
Projets du Fablab
All Projects
Projets du Fablab
Overview
Activity
News
Documents
Wiki
Files
Download (1.2 KB)
La Serveuse Automate
» code_led.ino
Programme de commande des LED -
Thomas Coment
, 11/23/2020 04:34 PM
//déclaration des variables
int
pinBouton
,
pinLed
;
boolean
etatAllumage
;
void
setup
()
//initialisation des variables
{
Serial
.
begin
(
9600
);
//nombre de bits par seconde
pinBouton
=
2
;
//le bouton poussoir est connecté au pin 2
pinLed
=
4
;
//la Led est connectée au pins 4 av
etatAllumage
=
0
;
//définition des modes
pinMode
(
pinBouton
,
INPUT_PULLUP
);
//bouton poussoir en entrée
pinMode
(
pinLed
,
OUTPUT
);
//led en sortie en sortie
}
void
loop
()
// entrée en boucle
{
Serial
.
print
(
etatAllumage
);
if
(
etatAllumage
)
//on teste si etatAllumage est à 1
{
digitalWrite
(
pinLed
,
HIGH
);
//on allume la LED
}
else
//sinon
{
digitalWrite
(
pinLed
,
LOW
);
//on éteint la LED
}
boolean
etatPinBouton
=
digitalRead
(
pinBouton
);
//lecture de l'état du bouton et stockage dans etatBouton
Serial
.
println
(
etatPinBouton
);
//test des conditions
if
(
!
etatPinBouton
)
//si bouton appuyé (donc le pin indique 0 car il est en mode INPUT_PULLUP)
{
if
(
etatAllumage
)
//si etatAllumage à 1
{
etatAllumage
=
0
;
//on le passe à 0
}
else
//sinon
{
etatAllumage
=
1
;
//on le passe à 1
}
}
delay
(
200
);
}
« Previous
1
…
13
14
15
Next »
(15-15/15)
Loading...