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.
Dependencies: mbed
main.cpp
- Committer:
- Giamarchi
- Date:
- 2019-01-12
- Revision:
- 0:531f33a2550d
- Child:
- 1:95172f59262a
File content as of revision 0:531f33a2550d:
/*************************************/
// YNCREA ISEN CSI3
// Electronique Numérique
//
// Cours : Systèmes à microcontrôleur
// Prof : Frédéric Giamarchi
//
// Exo 2.2 : Clignotemment de plusieurs Dels
/*************************************/
#include "mbed.h"
DigitalOut L0(PB_1);
DigitalOut L1(PB_2);
DigitalOut L2(PB_10);
DigitalOut L3(PB_11);
DigitalOut L4(PB_12);
DigitalOut L5(PB_13);
DigitalOut L6(PB_14);
DigitalOut L7(PB_15);
uint8_t L[8] = {L0, L1, L2, L3, L4, L5, L6, L7};
void set_8Dels(uint8_t position)
{
L0 = position & 0x01;
L1 = position & 0x02;
L2 = position & 0x04;
L3 = position & 0x08;
L4 = position & 0x10;
L5 = position & 0x20;
L6 = position & 0x40;
L7 = position & 0x80;
// L[!position] = 0;
// L[position] = 1;
}
uint8_t compteur = 1;
uint8_t sens = 0;
int main()
{
while(1)
{
wait(0.2); // 200 ms
if(!sens)
{
compteur<<=1; // décalage d'un bit vers la gauche
if(compteur == 0x80)
sens = 1;
}
else
{
compteur>>=1; // décalage d'un bit vers la droite
if(compteur == 0x01)
sens = 0;
}
set_8Dels(compteur);
}
}