Robert Buch / Mbed 2 deprecated compile

Dependencies:   mbed

Committer:
robertbuc
Date:
Mon Jan 13 17:32:06 2020 +0000
Revision:
3:380bc168e247
Parent:
2:db4c700f1898
Child:
4:179695a6d7fd
nibble und printb, nibble nochmal

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robertbuc 0:136627249b57 1 /*
robertbuc 0:136627249b57 2 weitere viele Beispiele in meinem WIKI
robertbuc 1:06d6570e52bc 3
robertbuc 1:06d6570e52bc 4 */
robertbuc 2:db4c700f1898 5
robertbuc 1:06d6570e52bc 6 #include "mbed.h"
robertbuc 1:06d6570e52bc 7 //#define BUTTON1 p14
robertbuc 1:06d6570e52bc 8 //#define BUTTON1 A1
robertbuc 0:136627249b57 9
robertbuc 0:136627249b57 10
robertbuc 1:06d6570e52bc 11 void nibbleLeds(int value);
robertbuc 2:db4c700f1898 12 void printb(uint8_t x);
robertbuc 0:136627249b57 13
robertbuc 1:06d6570e52bc 14 BusOut myleds(LED1,LED2,LED3,LED4);
robertbuc 0:136627249b57 15 DigitalIn button(BUTTON1);
robertbuc 0:136627249b57 16
robertbuc 0:136627249b57 17 const int INIT=0x03;
robertbuc 0:136627249b57 18
robertbuc 0:136627249b57 19 int main()
robertbuc 0:136627249b57 20 {
robertbuc 1:06d6570e52bc 21 int anzahl,anz;
robertbuc 1:06d6570e52bc 22 uint8_t value=INIT;
robertbuc 2:db4c700f1898 23
robertbuc 1:06d6570e52bc 24
robertbuc 1:06d6570e52bc 25 nibbleLeds(value);
robertbuc 2:db4c700f1898 26 printb(value);
robertbuc 1:06d6570e52bc 27 wait(0.1);
robertbuc 1:06d6570e52bc 28 }
robertbuc 1:06d6570e52bc 29
robertbuc 2:db4c700f1898 30 void printb(uint8_t x)
robertbuc 1:06d6570e52bc 31 {
robertbuc 2:db4c700f1898 32 for(int i=sizeof(x)<<3;i;i--)
robertbuc 2:db4c700f1898 33 putchar('0'+((x>>(i-1))&1));
robertbuc 2:db4c700f1898 34 printf("\n");
robertbuc 2:db4c700f1898 35 }
robertbuc 3:380bc168e247 36
robertbuc 3:380bc168e247 37 void nibbleLeds(int value)
robertbuc 3:380bc168e247 38 {
robertbuc 3:380bc168e247 39 myleds=value%16;
robertbuc 3:380bc168e247 40 }