![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
2 Tasten steuern 2 Interrupts welche 2 4bit Counter bedienen
Diff: main.cpp
- Revision:
- 1:62778ff59cc8
- Parent:
- 0:7a20a6aa1f5e
--- a/main.cpp Fri Feb 15 15:13:19 2013 +0000 +++ b/main.cpp Fri Nov 22 15:03:43 2019 +0000 @@ -1,17 +1,36 @@ +/* ********************************************************** */ +/* *************** Projekt: BuNuc_Interrupt_Taste *********** */ +/* BULME Graz, Abteilung Elektronik und Technische Informatik */ +/* ********************************************************** */ +// 2 Tasten bedienen je einen 4 bit Zähler, Visualisierung durch LED #include "mbed.h" -InterruptIn button(p5); -DigitalOut led(LED1); -DigitalOut flash(LED4); +InterruptIn taste1 (A1); +InterruptIn taste2 (A2); +BusOut vtaste1(D11, D12, A6, D13); +BusOut vtaste2(D2, D3, D6, D9); +DigitalOut rgb(D0); + +short counter1, counter2; -void flip() { - led = !led; +void flip1() // Interruptprogramm 1 +{ + vtaste1 = ++counter1; + if(vtaste1==16) counter1=0; } +void flip2() // Interruptprogramm 2 + { + vtaste2 = ++counter2; + if(vtaste2==16) counter2=0; + } -int main() { - button.rise(&flip); // attach the address of the flip function to the rising edge - while(1) { // wait around, interrupts will interrupt this! - flash = !flash; +int main() +{ + taste1.fall(&flip1); // attach the address of the flip function to the falling edge + taste2.fall(&flip2); // attach the address of the flip function to the falling edge + while(1) + { // wait around, interrupts will interrupt this! + rgb = !rgb; wait(0.25); } } \ No newline at end of file