Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Taster_Entprellen by
main.cpp@10:ba816c404c3c, 2018-10-08 (annotated)
- Committer:
- Lenschinki
- Date:
- Mon Oct 08 08:04:45 2018 +0000
- Revision:
- 10:ba816c404c3c
- Parent:
- 9:a4a4f8cc4019
Taster Entprellen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andcor02 | 0:80032665d37e | 1 | #include "mbed.h" |
KStefan | 8:0f74264cc38a | 2 | #include "SB1602E.h" |
Lenschinki | 10:ba816c404c3c | 3 | #include "debounceIn.h" |
andcor02 | 5:1fca2683ae6f | 4 | #define USE_I2C_2V8 |
andcor02 | 0:80032665d37e | 5 | |
KStefan | 9:a4a4f8cc4019 | 6 | DigitalOut myled(P0_8); // 7=rot, 8=grün, 9=blau |
Lenschinki | 10:ba816c404c3c | 7 | //DigitalIn sw_o(P0_12); |
Lenschinki | 10:ba816c404c3c | 8 | //DigitalIn sw_b(P0_13); |
Lenschinki | 10:ba816c404c3c | 9 | //DigitalIn sw_g(P0_14); |
Lenschinki | 10:ba816c404c3c | 10 | |
Lenschinki | 10:ba816c404c3c | 11 | InterruptIn redButton(P0_12); |
Lenschinki | 10:ba816c404c3c | 12 | InterruptIn blueButton(P0_13); |
Lenschinki | 10:ba816c404c3c | 13 | InterruptIn greenButton(P0_14); |
andcor02 | 5:1fca2683ae6f | 14 | |
KStefan | 9:a4a4f8cc4019 | 15 | I2C i2c_disp(P0_5, P0_4); // SDA, SCL auf LPC11U24 |
KStefan | 9:a4a4f8cc4019 | 16 | SB1602E lcd(i2c_disp); |
andcor02 | 5:1fca2683ae6f | 17 | |
KStefan | 9:a4a4f8cc4019 | 18 | int count_o, count_b, count_g = 0; |
andcor02 | 0:80032665d37e | 19 | |
Lenschinki | 10:ba816c404c3c | 20 | void btnRedPressed() |
Lenschinki | 10:ba816c404c3c | 21 | { |
Lenschinki | 10:ba816c404c3c | 22 | wait_us(200); |
Lenschinki | 10:ba816c404c3c | 23 | if(redButton == 0) |
Lenschinki | 10:ba816c404c3c | 24 | count_o++; |
Lenschinki | 10:ba816c404c3c | 25 | } |
Lenschinki | 10:ba816c404c3c | 26 | |
Lenschinki | 10:ba816c404c3c | 27 | void btnBluePressed() |
Lenschinki | 10:ba816c404c3c | 28 | { |
Lenschinki | 10:ba816c404c3c | 29 | wait_us(200); |
Lenschinki | 10:ba816c404c3c | 30 | if(blueButton == 0) |
Lenschinki | 10:ba816c404c3c | 31 | count_b++; |
Lenschinki | 10:ba816c404c3c | 32 | } |
Lenschinki | 10:ba816c404c3c | 33 | |
Lenschinki | 10:ba816c404c3c | 34 | void btnGreenPressed() |
Lenschinki | 10:ba816c404c3c | 35 | { |
Lenschinki | 10:ba816c404c3c | 36 | wait_us(200); |
Lenschinki | 10:ba816c404c3c | 37 | if(greenButton == 0) |
Lenschinki | 10:ba816c404c3c | 38 | count_g++; |
Lenschinki | 10:ba816c404c3c | 39 | } |
Lenschinki | 10:ba816c404c3c | 40 | |
andcor02 | 0:80032665d37e | 41 | int main() |
andcor02 | 0:80032665d37e | 42 | { |
KStefan | 9:a4a4f8cc4019 | 43 | lcd.printf(0, "Red Blue Green\r"); // Parameter von printf auf LCD: Zeilennummer (0 or 1), string |
Lenschinki | 10:ba816c404c3c | 44 | |
Lenschinki | 10:ba816c404c3c | 45 | redButton.mode(PullUp); |
Lenschinki | 10:ba816c404c3c | 46 | blueButton.mode(PullUp); |
Lenschinki | 10:ba816c404c3c | 47 | greenButton.mode(PullUp); |
Lenschinki | 10:ba816c404c3c | 48 | |
Lenschinki | 10:ba816c404c3c | 49 | redButton.fall(&btnRedPressed); |
Lenschinki | 10:ba816c404c3c | 50 | blueButton.fall(&btnBluePressed); |
Lenschinki | 10:ba816c404c3c | 51 | greenButton.fall(&btnGreenPressed); |
Lenschinki | 10:ba816c404c3c | 52 | |
Lenschinki | 10:ba816c404c3c | 53 | while(1) |
Lenschinki | 10:ba816c404c3c | 54 | { |
KStefan | 9:a4a4f8cc4019 | 55 | lcd.printf( 1,1, "%d %d %d", count_o, count_b, count_g); |
KStefan | 8:0f74264cc38a | 56 | myled = !myled; |
andcor02 | 0:80032665d37e | 57 | } |
andcor02 | 2:587b4d7444d1 | 58 | } |