Fatima Vunic
/
mbed_test
Test Programm
main.cpp@2:b43b5da6f341, 2020-01-13 (annotated)
- Committer:
- fatima365
- Date:
- Mon Jan 13 17:37:00 2020 +0000
- Revision:
- 2:b43b5da6f341
- Parent:
- 1:b6f2a3f6e8eb
- Child:
- 3:9be1093ae35e
3. Funk
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fatima365 | 0:7b78c5f07317 | 1 | #include "mbed.h" |
fatima365 | 0:7b78c5f07317 | 2 | #define BUTTON1 p14 // M3: push joystick pin |
fatima365 | 0:7b78c5f07317 | 3 | //#define BUTTON A1 // NUCLEO:Taster A1 |
fatima365 | 0:7b78c5f07317 | 4 | |
fatima365 | 0:7b78c5f07317 | 5 | //int modifybBit (int x, unsigned char position, bool State); |
fatima365 | 0:7b78c5f07317 | 6 | //int lauflicht (bool richtung, int time, int &anz); |
fatima365 | 1:b6f2a3f6e8eb | 7 | void nibbleLeds (int value); |
fatima365 | 2:b43b5da6f341 | 8 | void printb (uint8_t x); |
fatima365 | 0:7b78c5f07317 | 9 | |
fatima365 | 0:7b78c5f07317 | 10 | BusOut myleds(LED1, LED2, LED3, LED4); |
fatima365 | 0:7b78c5f07317 | 11 | DigitalIn button(BUTTON1); |
fatima365 | 0:7b78c5f07317 | 12 | |
fatima365 | 0:7b78c5f07317 | 13 | const int INIT = 0x03; |
fatima365 | 0:7b78c5f07317 | 14 | |
fatima365 | 0:7b78c5f07317 | 15 | int main() { |
fatima365 | 1:b6f2a3f6e8eb | 16 | int anzahl, anz; |
fatima365 | 1:b6f2a3f6e8eb | 17 | uint8_t value = INIT; |
fatima365 | 1:b6f2a3f6e8eb | 18 | |
fatima365 | 1:b6f2a3f6e8eb | 19 | nibbleLeds(value); |
fatima365 | 1:b6f2a3f6e8eb | 20 | wait (0.1); |
fatima365 | 1:b6f2a3f6e8eb | 21 | } |
fatima365 | 2:b43b5da6f341 | 22 | void printb (uint8_t x){ |
fatima365 | 2:b43b5da6f341 | 23 | for (int i = sizeof(x)<<3; i; i--) |
fatima365 | 2:b43b5da6f341 | 24 | putchar('0'+((x>>(i-1))&1)); |
fatima365 | 2:b43b5da6f341 | 25 | printf("\n"); |
fatima365 | 2:b43b5da6f341 | 26 | } |
fatima365 | 1:b6f2a3f6e8eb | 27 | |
fatima365 | 1:b6f2a3f6e8eb | 28 | void nibbleLeds(int value){ |
fatima365 | 1:b6f2a3f6e8eb | 29 | myleds = value%16; |
fatima365 | 1:b6f2a3f6e8eb | 30 | } |