![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
s
main.cpp
- Committer:
- an3
- Date:
- 2020-02-04
- Revision:
- 0:921e0ef4606b
File content as of revision 0:921e0ef4606b:
#include "mbed.h" #include "C12832.h" Serial pc(USBTX, USBRX); // tx, rx DigitalOut led(LED1); Thread blinky; Thread joythread; PwmOut led1 (LED1); DigitalIn down(A3); DigitalIn up(A2); BusIn joy(p15,p12,p13,p16); unsigned int ton_off = 1000; void plus100(){ ton_off=ton_off+100; if(ton_off<2000){ ton_off=2000; } } void minus100(){ ton_off=ton_off-100; if(ton_off<200){ ton_off=200; } } void Joy_of_thread() { for(;;) { if(up){ plus100(); //p15.rise(&plus100); pc.printf("wartezeit zwischen ein-aus:%d",ton_off); } if(down){ minus100(); //p12.rise(&minus100); pc.printf("wartezeit zwischen ein-aus:%d",ton_off); } thread_sleep_for(10);//fragen sie alle 10ms die tasten ab } } void blinky_thread() { for(;;) //wie while(true), es ist aber grad in. { led1=1; thread_sleep_for(ton_off); led1=0; thread_sleep_for(ton_off); } } int main() { blinky.start(blinky_thread); joythread.start(Joy_of_thread); while(1){ wait(1); } } // Klammern {} Gross-klein schreibung while()