Kiraly Stefan Istvan
/
BUTTON
stm32f103c8t6 push buton functionality examples
Revision 0:3bfafa38794c, committed 2017-11-29
- Comitter:
- yo2lts
- Date:
- Wed Nov 29 04:54:48 2017 +0000
- Commit message:
- STM32nucleo push button
Changed in this revision
diff -r 000000000000 -r 3bfafa38794c PinDetect.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PinDetect.lib Wed Nov 29 04:54:48 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/AjK/code/PinDetect/#cb3afc45028b
diff -r 000000000000 -r 3bfafa38794c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 29 04:54:48 2017 +0000 @@ -0,0 +1,36 @@ +// 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 + } +}
diff -r 000000000000 -r 3bfafa38794c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 29 04:54:48 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90 \ No newline at end of file