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:
- 0:a64165168954
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Apr 27 13:03:05 2010 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "PCA9532.h"
+
+PCA9532 leds (p28, p27, 0xc0);
+
+int main() {
+
+ // Set LED15 to blink
+ leds.Period(1, 0.1);
+ leds.Duty(1, 0.5);
+ leds.SetLed(15, MODE_PWM1);
+
+ // LED0-14 will fade up in turn, the reset
+
+ while (1) {
+
+ // 0x7FFF enables LED 0-14, which are being switched off
+ leds.SetMode(0x7fff, MODE_OFF);
+
+ // For each LED in turn
+ for (int i = 0 ; i < 15 ; i++) {
+
+ // Switch PWM to off, and connect LED(i)
+ leds.Duty(0, 0.0);
+ leds.SetLed(i, MODE_PWM0);
+
+ // Fade LED(i) from 0 to 1.0
+ for (float j = 0.0 ; j < 1.0 ; j+=0.01) {
+ leds.Duty(0,j);
+ wait(0.005);
+ }
+
+ // Set LED(i) to continuously ON
+ // this stops it fading out and in again with LED(i+1)
+ leds.SetLed(i, MODE_ON);
+ wait (0.01);
+
+ }
+
+ } // while(1)
+} // main
+