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 mbed-cloud-connect-sensor-laser-distance by
main.cpp@9:f2bdb2a79528, 2018-12-10 (annotated)
- Committer:
- KStefan
- Date:
- Mon Dec 10 07:22:31 2018 +0000
- Revision:
- 9:f2bdb2a79528
- Parent:
- 8:0f74264cc38a
OK
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" |
andcor02 | 5:1fca2683ae6f | 3 | #define USE_I2C_2V8 |
KStefan | 9:f2bdb2a79528 | 4 | #include "DebounceIn.h" |
andcor02 | 0:80032665d37e | 5 | |
KStefan | 9:f2bdb2a79528 | 6 | DigitalOut myled(P0_8); // 7=rot, 8=grün, 9=blau |
KStefan | 9:f2bdb2a79528 | 7 | DigitalIn sw_o(P0_12); |
KStefan | 9:f2bdb2a79528 | 8 | InterruptIn sw_b(P0_13); |
KStefan | 9:f2bdb2a79528 | 9 | InterruptIn sw_g(P0_14); |
KStefan | 9:f2bdb2a79528 | 10 | Ticker ticker1; |
KStefan | 9:f2bdb2a79528 | 11 | |
andcor02 | 5:1fca2683ae6f | 12 | |
KStefan | 9:f2bdb2a79528 | 13 | I2C i2c_disp(P0_5, P0_4); // SDA, SCL auf LPC11U24 |
KStefan | 9:f2bdb2a79528 | 14 | SB1602E lcd(i2c_disp); |
andcor02 | 5:1fca2683ae6f | 15 | |
KStefan | 9:f2bdb2a79528 | 16 | int count_o, count_b, count_g = 0; |
andcor02 | 5:1fca2683ae6f | 17 | |
KStefan | 9:f2bdb2a79528 | 18 | void blue(){ |
KStefan | 9:f2bdb2a79528 | 19 | count_b++; |
andcor02 | 5:1fca2683ae6f | 20 | } |
KStefan | 9:f2bdb2a79528 | 21 | void green() { |
KStefan | 9:f2bdb2a79528 | 22 | count_g++; |
KStefan | 9:f2bdb2a79528 | 23 | } |
andcor02 | 0:80032665d37e | 24 | |
andcor02 | 0:80032665d37e | 25 | int main() |
KStefan | 9:f2bdb2a79528 | 26 | { |
KStefan | 9:f2bdb2a79528 | 27 | lcd.printf(0, "Red Blue Green\r"); // Parameter von printf auf LCD: Zeilennummer (0 or 1), string |
KStefan | 9:f2bdb2a79528 | 28 | while(1) { |
KStefan | 8:0f74264cc38a | 29 | |
KStefan | 9:f2bdb2a79528 | 30 | lcd.printf(1,1, "%d %d %d", count_o, count_b, count_g); |
KStefan | 8:0f74264cc38a | 31 | |
KStefan | 8:0f74264cc38a | 32 | myled = !myled; |
KStefan | 9:f2bdb2a79528 | 33 | |
andcor02 | 0:80032665d37e | 34 | } |
andcor02 | 2:587b4d7444d1 | 35 | } |