Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- julienbltt
- Date:
- 2021-04-26
- Revision:
- 1:331b2ab21c68
- Parent:
- 0:53ef7654cca2
- Child:
- 2:2992ec32f76f
File content as of revision 1:331b2ab21c68:
// EXERCICE N°2 : CHANGEMENT DE COULEUR DE LA LED EN FONCTION DE LA POSITION DU POTENTIOMETRE.
// Diagrame :
// START
// |<-----------------------|
// valA2 = lire A2 |
// | |
// |- if valA2<0.15 o-| |
// | | |
// VERT |- if valA2<0.3 o-| |
// | | | |
// | BLEU ROUGE |
// | | | |
// ----------------------------------|
#include "mbed.h"
enum COULEUR{
NOIR = 0b111,
ROUGE = 0b011,
VERT = 0b101,
BLEU = 0b110,
JAUNE = 0b001,
ROSE = 0b010,
AZUR = 0b100,
BLANC = 0b000
};
BusOut leds(LED3,LED2,LED1);
AnalogIn pot(A2);
int main() {
// Déclaration des variables local.
float valA2;
while(true)
{
// Lecture des entrées.
valA2 = pot;
// Algorithme.
if(valA2<0.15) {
leds.write(VERT);
}
else {
if(valA2<0.3) {
leds.write(BLEU);
}
else {
leds.write(ROUGE);
}
}
// Fin algo.
}
}