David Charalampous
/
Test_baseboard
mx basebaord
Diff: Test_baseboard.cpp
- Revision:
- 0:10568a3d517a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Test_baseboard.cpp Tue Nov 18 09:28:29 2014 +0000 @@ -0,0 +1,90 @@ +#include "mbed.h" //bibliothèque Mbed +#include "TextLCD.h" + + +//Serial pc(USBTX, USBRX); //tx,rx pc est un objet de la classe +DigitalOut myled(LED1); +DigitalOut myled2(LED2); +DigitalOut myled3(LED3); +DigitalOut myled4(LED4); +AnalogIn period(p20); +DigitalOut buzz(p24); +//int buzz; +InterruptIn button(p11); +PwmOut pTest(p26); + + +TextLCD lcd(p14,p19,p25,p23,p22,p21); //rs, e, d4-d7 + + +float delayed=0.01; + +void davLed(int f){ + if( f==0) myled=0; + if( f==1) myled=1; + if( f==3){ + delayed=0.01+period; + myled = 1; + myled2 = 0; + myled3 = 0; + myled4 = 0; + delayed=0.01+period; + wait(delayed); + myled2 = 1; + myled = 0; + + delayed=0.01+period; + wait(delayed); + myled2 = 0; + myled3 = 1; + delayed=0.01+period; + wait(delayed); + myled3 = 0; + myled4 = 1; + delayed=0.01+period; + wait(delayed); + lcd.cls(); + lcd.printf("Periode= %.2f s",delayed); + } +} +void flip(){ + int bip=buzz; + + if(bip==1){ + buzz=0; + }else{ + buzz=1; + } +} + + +int main() { + // int i=0; + // int c=0; + + //pc.baud(115200); // débit en bauds + //pc.printf("MBDE\r\n"); + buzz=1; + pTest.period_us(1); + lcd.printf("Test\n"); + wait(0.5); + while(1){ + button.fall(&flip); + pTest.write(period); + + //pc.printf("%d\r\n",i); + //i++; + //wait(1.0); + /*if(pc.readable()){ + c=pc.getc(); + if(c=='0'){davLed(0);} + + if(c=='1'){davLed(1);} + if(c=='3'){davLed(3);}*/ + + davLed(3); + } + + + +} \ No newline at end of file