haha yes
Fork of Taster_Entprellen by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "SB1602E.h" 00003 #include "debounceIn.h" 00004 #define USE_I2C_2V8 00005 00006 DigitalOut myled(P0_8); // 7=rot, 8=grün, 9=blau 00007 //DigitalIn sw_o(P0_12); 00008 //DigitalIn sw_b(P0_13); 00009 //DigitalIn sw_g(P0_14); 00010 00011 InterruptIn redButton(P0_12); 00012 InterruptIn blueButton(P0_13); 00013 InterruptIn greenButton(P0_14); 00014 00015 I2C i2c_disp(P0_5, P0_4); // SDA, SCL auf LPC11U24 00016 SB1602E lcd(i2c_disp); 00017 00018 int count_o, count_b, count_g = 0; 00019 00020 void btnRedPressed() 00021 { 00022 wait_us(200); 00023 if(redButton == 0) 00024 count_o++; 00025 } 00026 00027 void btnBluePressed() 00028 { 00029 wait_us(200); 00030 if(blueButton == 0) 00031 count_b++; 00032 } 00033 00034 void btnGreenPressed() 00035 { 00036 wait_us(200); 00037 if(greenButton == 0) 00038 count_g++; 00039 } 00040 00041 int main() 00042 { 00043 lcd.printf(0, "Red Blue Green\r"); // Parameter von printf auf LCD: Zeilennummer (0 or 1), string 00044 00045 redButton.mode(PullUp); 00046 blueButton.mode(PullUp); 00047 greenButton.mode(PullUp); 00048 00049 redButton.fall(&btnRedPressed); 00050 blueButton.fall(&btnBluePressed); 00051 greenButton.fall(&btnGreenPressed); 00052 00053 while(1) 00054 { 00055 lcd.printf( 1,1, "%d %d %d", count_o, count_b, count_g); 00056 myled = !myled; 00057 } 00058 }
Generated on Sat Jul 23 2022 03:56:00 by
1.7.2
BULME_AHEL20
