cherif bend ahmane
/
EX25et26
qsfqsd
Fork of EX25 by
main.cpp
- Committer:
- chifterben94
- Date:
- 2017-02-03
- Revision:
- 1:ca389bf1cec5
- Parent:
- 0:c09709a8f2f0
File content as of revision 1:ca389bf1cec5:
#include "mbed.h" #include "C12832.h" Serial pc (USBTX,USBRX,9600); BusIn joy(D4,A4,A5,A3,A2); DigitalOut green(PC_7); AnalogIn Pot1 (A0); C12832 ecran (D11,D13,D12,D7,D10); Ticker ticker; Ticker ticker2; char caractere = 0; char mot[100] = "Bonjour"; int etat = 1; int nbCarac = 0; int transmissionActive = 0; int nbEnvoi = 1; void allumerEteindre() { green.write(etat); } void envoyerBonjour() { if(transmissionActive == 1 && nbEnvoi < 7*5 ){ pc.putc(mot[nbCarac]); nbCarac ++; nbEnvoi ++; if(nbCarac == 7) { nbCarac = 0; } } } int main() { ticker.attach(&allumerEteindre,0.25); pc.attach(&envoyerBonjour,pc.TxIrq); while(1) { caractere = (char) (0x5f - 0x20) * Pot1.read() + 0x20; ecran.cls(); ecran.locate(0,0); ecran.printf("%c",caractere); switch (joy) { case 0x08 : // en bas etat = 1; break; case 0x10 : //en haut transmissionActive = 0; if(pc.writeable()) { pc.putc(caractere); etat = 0; while (joy == 0x10){} } break; case 0x01 : // enfoncer transmissionActive = 1; pc.putc(' '); nbEnvoi = 0; etat = 1; while (joy == 0x01){} break; } wait(0.1); } }