main

Dependencies:   mbed

Committer:
stefanblack
Date:
Mon Jan 13 17:49:40 2020 +0000
Revision:
2:966a09f3c106
Parent:
1:e15f803c8fe9
nibbleLeds()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stefanblack 0:c05b0b112054 1 #include "mbed.h"
stefanblack 0:c05b0b112054 2
stefanblack 2:966a09f3c106 3 void printb(uint8_t x);
stefanblack 1:e15f803c8fe9 4 void nibbleLeds(int value);
stefanblack 1:e15f803c8fe9 5
stefanblack 0:c05b0b112054 6 BusOut myleds(LED1,LED2,LED3,LED4);
stefanblack 0:c05b0b112054 7 DigitalIn button(BUTTON1);
stefanblack 0:c05b0b112054 8
stefanblack 0:c05b0b112054 9 const int INIT=0x03;
stefanblack 0:c05b0b112054 10
stefanblack 0:c05b0b112054 11 int main() {
stefanblack 1:e15f803c8fe9 12
stefanblack 1:e15f803c8fe9 13 int anzahl, anz;
stefanblack 1:e15f803c8fe9 14 uint8_t value=INIT;
stefanblack 1:e15f803c8fe9 15
stefanblack 1:e15f803c8fe9 16 nibbleLeds(value);
stefanblack 2:966a09f3c106 17 printb(value);
stefanblack 1:e15f803c8fe9 18 wait(0.1);
stefanblack 1:e15f803c8fe9 19
stefanblack 0:c05b0b112054 20 }
stefanblack 1:e15f803c8fe9 21
stefanblack 2:966a09f3c106 22 void printb(uint8_t)
stefanblack 2:966a09f3c106 23 {
stefanblack 2:966a09f3c106 24 for(int i=sizeof(x)<<3;i;i--)
stefanblack 2:966a09f3c106 25 putchar('0'+((x>>(i-1))&1));
stefanblack 2:966a09f3c106 26 printf("\n");
stefanblack 2:966a09f3c106 27
stefanblack 1:e15f803c8fe9 28 void nibbleLeds(int value)
stefanblack 1:e15f803c8fe9 29 {
stefanblack 1:e15f803c8fe9 30 myleds=value%16;
stefanblack 1:e15f803c8fe9 31 }