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:
- 2:7cdadcca2c06
- Parent:
- 1:6c8d46a9c3c9
diff -r 6c8d46a9c3c9 -r 7cdadcca2c06 main.cpp
--- a/main.cpp Tue May 11 21:15:44 2010 +0000
+++ b/main.cpp Tue May 11 21:25:52 2010 +0000
@@ -1,53 +1,53 @@
-#include "mbed.h"
-
-DigitalOut myled1(LED1);
-DigitalOut myled2(LED2);
-DigitalOut myled3(LED3);
-DigitalOut myled4(LED4);
-
-void update_leds (int myleds)
-{
- // update the LEDs
- myled1 = myleds & 1;
- myled2 = (myleds & 2) >> 1;
- myled3 = (myleds & 4) >> 2;
- myled4 = (myleds & 8) >> 3;
-}
-
-int main()
-{
- unsigned int count, count_up, speed_up = 0 ;
- float count_interval = 1.0;
-
- count_up = ~ count_up;
-
- while(1)
- {
- // update LEDs with the current count value
- update_leds (count);
-
- // count up or down depending on the value of count_up
- if (count_up)
- count++;
- else
- count--;
-
- // interval to next count
- wait(count_interval);
-
- // update the count interval when the LED count gets to 16
- // decrement the interval every 16 lots of counts
- if (speed_up && count % 16 == 0)
- count_interval /= 2;
- else if (count % 16 == 0)
- count_interval *= 2;
-
- if (count % 256 == 0)
- speed_up = ~ speed_up;
-
- // change the count direction every 32 lots of counts
- if (count % 512 == 0)
- count_up = ~ count_up;
-
- }
-}
+#include "mbed.h"
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+void update_leds (int myleds)
+{
+ // update the LEDs
+ myled1 = myleds & 1;
+ myled2 = (myleds & 2) >> 1;
+ myled3 = (myleds & 4) >> 2;
+ myled4 = (myleds & 8) >> 3;
+}
+
+int main()
+{
+ unsigned int count, count_up, speed_up = 0 ;
+ float count_interval = 0.1;
+
+ count_up = ~ count_up;
+
+ while(1)
+ {
+ // update LEDs with the current count value
+ update_leds (count);
+
+ // count up or down depending on the value of count_up
+ if (count_up)
+ count++;
+ else
+ count--;
+
+ // interval to next count
+ wait(count_interval);
+
+ // update the count interval when the LED count gets to 16
+ // decrement the interval every 16 lots of counts
+ if (speed_up && count % 16 == 0)
+ count_interval /= 2;
+ else if (count % 16 == 0)
+ count_interval *= 2;
+
+ if (count % 256 == 0)
+ speed_up = ~ speed_up;
+
+ // change the count direction every 32 lots of counts
+ if (count % 512 == 0)
+ count_up = ~ count_up;
+
+ }
+}