Stefan Kiegerl
/
run_test
run test
main.cpp@3:6041499f4c0f, 2020-01-13 (annotated)
- Committer:
- stkiegerl
- Date:
- Mon Jan 13 17:28:20 2020 +0000
- Revision:
- 3:6041499f4c0f
- Parent:
- 2:da59c940bc1b
- Child:
- 4:58f30b934b59
fixed error with button1 double define
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stkiegerl | 0:c9cfffb3a319 | 1 | #include "mbed.h" |
stkiegerl | 1:f92ffd7d6a00 | 2 | #define BUTTON1 p14 // M3: push joystick pin |
stkiegerl | 3:6041499f4c0f | 3 | //#define BUTTON1 A1 // NUCLEO: Taster A1 |
stkiegerl | 1:f92ffd7d6a00 | 4 | |
stkiegerl | 3:6041499f4c0f | 5 | void printb(uint8_t x); |
stkiegerl | 1:f92ffd7d6a00 | 6 | void nibbleLeds(int value); |
stkiegerl | 0:c9cfffb3a319 | 7 | |
stkiegerl | 0:c9cfffb3a319 | 8 | BusOut myleds(LED1, LED2, LED3, LED4); |
stkiegerl | 0:c9cfffb3a319 | 9 | DigitalIn button(BUTTON1); |
stkiegerl | 0:c9cfffb3a319 | 10 | |
stkiegerl | 0:c9cfffb3a319 | 11 | const int INIT = 0x03; |
stkiegerl | 0:c9cfffb3a319 | 12 | |
stkiegerl | 0:c9cfffb3a319 | 13 | int main () { |
stkiegerl | 1:f92ffd7d6a00 | 14 | int anzahl, anz; |
stkiegerl | 1:f92ffd7d6a00 | 15 | uint8_t value = INIT; |
stkiegerl | 1:f92ffd7d6a00 | 16 | |
stkiegerl | 1:f92ffd7d6a00 | 17 | nibbleLeds(value); |
stkiegerl | 2:da59c940bc1b | 18 | printb(value); |
stkiegerl | 1:f92ffd7d6a00 | 19 | wait(0.1); |
stkiegerl | 1:f92ffd7d6a00 | 20 | } |
stkiegerl | 1:f92ffd7d6a00 | 21 | |
stkiegerl | 2:da59c940bc1b | 22 | void printb(uint8_t x){ |
stkiegerl | 2:da59c940bc1b | 23 | for(int i = sizeof(x)<<3; i; i--){ |
stkiegerl | 2:da59c940bc1b | 24 | putchar('0'+((x>>(i-1))&1)); |
stkiegerl | 2:da59c940bc1b | 25 | printf("\n"); |
stkiegerl | 2:da59c940bc1b | 26 | } |
stkiegerl | 2:da59c940bc1b | 27 | } |
stkiegerl | 2:da59c940bc1b | 28 | |
stkiegerl | 1:f92ffd7d6a00 | 29 | void nibbleLeds(int value){ |
stkiegerl | 1:f92ffd7d6a00 | 30 | myleds = value%16; |
stkiegerl | 0:c9cfffb3a319 | 31 | } |