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.
Revision 3:21631924f2f1, committed 2020-01-13
- Comitter:
- mirzamesic
- Date:
- Mon Jan 13 17:32:26 2020 +0000
- Parent:
- 2:4b37034bf874
- Child:
- 4:6eb0d62c4fbf
- Commit message:
- main_mit_lauflicht
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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)
{