![](/media/cache/profiles/Screen_Shot_2017-08-23_at_23.59.01.png.50x50_q85.png)
stm32f103c8t6 push buton functionality examples
main.cpp
- Committer:
- yo2lts
- Date:
- 2017-11-29
- Revision:
- 0:3bfafa38794c
File content as of revision 0:3bfafa38794c:
// PINUL DIGITAL PA_8 vine pus la 3.3V printr-o rezistenta de 4.7k ohm ca si cum ai apasa butonul, example in librarie .h #include "mbed.h" #include "PinDetect.h" PinDetect pin(PB_9); //PA_8 DigitalOut myled(LED1); Serial pc(PA_2, PA_3); // tx, rx pc terminalra valo kiiras void keyPressed( void ) { pc.printf("AM APASAT BUTONUL SCURT"); myled = 0; // LED is OFF } void keyPressedHeld( void ) { pc.printf("am apasat butonul lung"); } int main() { pin.mode( PullDown ); pin.attach_asserted( &keyPressed ); //apesi butonul scurt pin.setSamplesTillHeld( 300 ); //tin apasat butonul vreo 5 secunde pin.attach_asserted_held( &keyPressedHeld ); //apesi butonul lung pin.setSampleFrequency(); // Defaults to 20ms. while(1) { pc.printf("START WHILE"); myled = 1; // LED is ON wait(0.2); // 200 ms // myled = 0; // LED is OFF // wait(1.0); // 1 sec } }