Mumin Hadzic
/
TINF_TestProgramm
Main
main.cpp@2:8784f9c96dca, 2020-01-13 (annotated)
- Committer:
- muminhadzic
- Date:
- Mon Jan 13 17:45:35 2020 +0000
- Revision:
- 2:8784f9c96dca
- Parent:
- 1:2513045fcb59
- Child:
- 3:aaaaf9f23f46
printb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
muminhadzic | 0:4c39745fe0c2 | 1 | #include "mbed.h" |
muminhadzic | 0:4c39745fe0c2 | 2 | #define BUTTON1 p14 |
muminhadzic | 0:4c39745fe0c2 | 3 | //#define BUTTON1 A1 |
muminhadzic | 0:4c39745fe0c2 | 4 | |
muminhadzic | 1:2513045fcb59 | 5 | //int lauflicht(bool richtung,int time, int &anz); |
muminhadzic | 0:4c39745fe0c2 | 6 | //int modifyBit(int x, unsigned char position, bool State); |
muminhadzic | 1:2513045fcb59 | 7 | void nibbleLeds(int value); |
muminhadzic | 2:8784f9c96dca | 8 | void printb(uint8_t x); |
muminhadzic | 0:4c39745fe0c2 | 9 | |
muminhadzic | 0:4c39745fe0c2 | 10 | BusOut myleds(LED1,LED2,LED3,LED4); |
muminhadzic | 0:4c39745fe0c2 | 11 | DigitalIn button(BUTTON1); |
muminhadzic | 0:4c39745fe0c2 | 12 | |
muminhadzic | 0:4c39745fe0c2 | 13 | const int INIT = 0x03; |
muminhadzic | 0:4c39745fe0c2 | 14 | |
muminhadzic | 1:2513045fcb59 | 15 | //************************************************************** |
muminhadzic | 0:4c39745fe0c2 | 16 | int main() { |
muminhadzic | 1:2513045fcb59 | 17 | |
muminhadzic | 1:2513045fcb59 | 18 | nibbleLeds(value); |
muminhadzic | 1:2513045fcb59 | 19 | wait(0.1); |
muminhadzic | 2:8784f9c96dca | 20 | printb(value); |
muminhadzic | 0:4c39745fe0c2 | 21 | |
muminhadzic | 0:4c39745fe0c2 | 22 | } |
muminhadzic | 1:2513045fcb59 | 23 | //************************************************************** |
muminhadzic | 0:4c39745fe0c2 | 24 | |
muminhadzic | 1:2513045fcb59 | 25 | void nibbleLeds(int value) { |
muminhadzic | 1:2513045fcb59 | 26 | myleds= value%16; |
muminhadzic | 2:8784f9c96dca | 27 | } |
muminhadzic | 2:8784f9c96dca | 28 | |
muminhadzic | 2:8784f9c96dca | 29 | void printb(uint8_t x){ |
muminhadzic | 2:8784f9c96dca | 30 | for(int i=sizeof(x)<<3;i;i--) |
muminhadzic | 2:8784f9c96dca | 31 | putchar('0'+((x>>(i-1))&1)); |
muminhadzic | 2:8784f9c96dca | 32 | printf("\n"); |
muminhadzic | 2:8784f9c96dca | 33 | |
muminhadzic | 1:2513045fcb59 | 34 | } |