Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 3:21631924f2f1
- Parent:
- 2:4b37034bf874
--- a/main.cpp Mon Jan 13 17:24:49 2020 +0000 +++ b/main.cpp Mon Jan 13 17:32:26 2020 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #define BUTTON1 p14 +int lauflicht(bool richtung, int time, int &anz); void nibbleLeds(int value); void printb(uint8_t x); @@ -11,13 +12,47 @@ int main() { - + int anzahl, anz; uint8_t value = INIT; + anzahl = lauflicht(true, 400, anz=0); + printf("anzahl = %d\n", anzahl); nibbleLeds(value); + printb(value); wait(0.1); } +int lauflicht(bool richtung, int time, int &anz) +{ + int i; + uint8_t lauf = 0x01; + + if(!richtung) + lauf= 0x08; + while(1) { + nibbleLeds(lauf&0x0F); + if(richtung) { + + lauf = lauf << 1; + if(lauf>8) + lauf = 0x01; + + } else { + lauf = lauf >>1; + if(lauf == 0) + lauf = 0x08; + } + if(button) + break; + wait_ms(time); + anz++; + + } + return anz; + + +} + void printb(uint8_t x) {