M0Board_WF
/
WF_lektion9-LM75B_einmal_lesen_LED_schreiben
a
main.cpp@1:b7965a82c352, 2015-01-28 (annotated)
- Committer:
- bulmenwt
- Date:
- Wed Jan 28 07:47:54 2015 +0000
- Revision:
- 1:b7965a82c352
- Parent:
- 0:1adfdceaa068
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bulmenwt | 0:1adfdceaa068 | 1 | /*M0-BOARD LPC11U24 VERSION 1.0 WF 11_2014 |
bulmenwt | 0:1adfdceaa068 | 2 | BULME Graz / Elektronik 29 |
bulmenwt | 0:1adfdceaa068 | 3 | Alternativ ohne Library für LM75B |
bulmenwt | 0:1adfdceaa068 | 4 | |
bulmenwt | 0:1adfdceaa068 | 5 | UART Raspberry PI lesen |
bulmenwt | 0:1adfdceaa068 | 6 | |
bulmenwt | 0:1adfdceaa068 | 7 | */ |
bulmenwt | 0:1adfdceaa068 | 8 | #include "mbed.h" |
bulmenwt | 0:1adfdceaa068 | 9 | #include "LM75B.h" |
bulmenwt | 0:1adfdceaa068 | 10 | |
bulmenwt | 0:1adfdceaa068 | 11 | DigitalOut Led1(LED1); |
bulmenwt | 0:1adfdceaa068 | 12 | DigitalOut Led2(LED2); |
bulmenwt | 0:1adfdceaa068 | 13 | DigitalOut Led3(LED3); |
bulmenwt | 0:1adfdceaa068 | 14 | DigitalOut Led4(LED4); |
bulmenwt | 0:1adfdceaa068 | 15 | |
bulmenwt | 0:1adfdceaa068 | 16 | Serial pc(USBTX, USBRX); // tx, rx |
bulmenwt | 0:1adfdceaa068 | 17 | char ch; |
bulmenwt | 0:1adfdceaa068 | 18 | |
bulmenwt | 0:1adfdceaa068 | 19 | //Create an LM75B object at the default address (ADDRESS_0) |
bulmenwt | 0:1adfdceaa068 | 20 | LM75B sensor(p28, p27); |
bulmenwt | 0:1adfdceaa068 | 21 | int main() |
bulmenwt | 0:1adfdceaa068 | 22 | { |
bulmenwt | 0:1adfdceaa068 | 23 | while (1) { |
bulmenwt | 0:1adfdceaa068 | 24 | printf("%.1f\n\r", (float)sensor); |
bulmenwt | 0:1adfdceaa068 | 25 | |
bulmenwt | 0:1adfdceaa068 | 26 | Led4=1; |
bulmenwt | 0:1adfdceaa068 | 27 | wait(0.2); |
bulmenwt | 0:1adfdceaa068 | 28 | Led4=0; |
bulmenwt | 0:1adfdceaa068 | 29 | wait(0.2); |
bulmenwt | 0:1adfdceaa068 | 30 | |
bulmenwt | 0:1adfdceaa068 | 31 | |
bulmenwt | 0:1adfdceaa068 | 32 | ch = pc.getc(); |
bulmenwt | 0:1adfdceaa068 | 33 | |
bulmenwt | 0:1adfdceaa068 | 34 | |
bulmenwt | 0:1adfdceaa068 | 35 | if (ch == 'a') { // LED |
bulmenwt | 1:b7965a82c352 | 36 | Led1 = 1; |
bulmenwt | 0:1adfdceaa068 | 37 | |
bulmenwt | 0:1adfdceaa068 | 38 | } |
bulmenwt | 0:1adfdceaa068 | 39 | |
bulmenwt | 0:1adfdceaa068 | 40 | else if (ch == 'b') { |
bulmenwt | 1:b7965a82c352 | 41 | Led1 = 0; |
bulmenwt | 0:1adfdceaa068 | 42 | |
bulmenwt | 0:1adfdceaa068 | 43 | } |
bulmenwt | 0:1adfdceaa068 | 44 | |
bulmenwt | 0:1adfdceaa068 | 45 | |
bulmenwt | 0:1adfdceaa068 | 46 | } |
bulmenwt | 0:1adfdceaa068 | 47 | } |
bulmenwt | 0:1adfdceaa068 | 48 | |
bulmenwt | 0:1adfdceaa068 | 49 | |
bulmenwt | 0:1adfdceaa068 | 50 |