mbed workshop intro + cansat examples

Files at this revision

API Documentation at this revision

Comitter:
yamaguch
Date:
Thu May 10 21:14:34 2012 +0000
Commit message:
1.0

Changed in this revision

Accel1.cpp Show annotated file Show diff for this revision Revisions of this file
Accel2.cpp Show annotated file Show diff for this revision Revisions of this file
Accel3.cpp Show annotated file Show diff for this revision Revisions of this file
Buzzer.cpp Show annotated file Show diff for this revision Revisions of this file
CanSat1.cpp Show annotated file Show diff for this revision Revisions of this file
CanSat2.cpp Show annotated file Show diff for this revision Revisions of this file
CanSat3.cpp Show annotated file Show diff for this revision Revisions of this file
Countdown1.cpp Show annotated file Show diff for this revision Revisions of this file
Countdown2.cpp Show annotated file Show diff for this revision Revisions of this file
Countdown3.cpp Show annotated file Show diff for this revision Revisions of this file
FileIO.cpp Show annotated file Show diff for this revision Revisions of this file
Interrupt.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed1.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed2.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed3.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed4.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed5.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed6.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed7.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed8.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed9.cpp Show annotated file Show diff for this revision Revisions of this file
MySw1.cpp Show annotated file Show diff for this revision Revisions of this file
MySw2.cpp Show annotated file Show diff for this revision Revisions of this file
PC.cpp Show annotated file Show diff for this revision Revisions of this file
RTC1.cpp Show annotated file Show diff for this revision Revisions of this file
RTC2.cpp Show annotated file Show diff for this revision Revisions of this file
Temp1.cpp Show annotated file Show diff for this revision Revisions of this file
Temp2.cpp Show annotated file Show diff for this revision Revisions of this file
Volume1.cpp Show annotated file Show diff for this revision Revisions of this file
Volume2.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f309f06aeec7 Accel1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Accel1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+AnalogIn x(p15);
+AnalogIn y(p16);
+AnalogIn z(p17);
+DigitalIn zeroGDetect(p25);
+DigitalOut gSelect(p26);
+DigitalOut sleep(p24);
+
+int main() {
+    gSelect = 1; // 6g mode
+    sleep = 1;   // do not sleep
+    
+    while (true) {
+        printf("x = %5.3f, y = %5.3f, z = %5.3f\n", x.read(), y.read(), z.read());
+        wait(1.0);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Accel2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Accel2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+
+AnalogIn x(p15);
+AnalogIn y(p16);
+AnalogIn z(p17);
+DigitalIn zeroGDetect(p25);
+DigitalOut gSelect(p26);
+DigitalOut sleep(p24);
+
+int main() {
+    gSelect = 1; // 6g mode
+    sleep = 1;   // do not sleep
+
+    while (true) {
+        float accelX = (x.read() * 3.3 - 1.65) / 0.206;
+        float accelY = (y.read() * 3.3 - 1.65) / 0.206;
+        float accelZ = (z.read() * 3.3 - 1.65) / 0.206;
+        printf("x = %5.3f, y = %5.3f, z = %5.3f\n", accelX, accelY, accelZ);
+        wait(1.0);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Accel3.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Accel3.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,14 @@
+#include "mbed.h"
+#include "MMA7361L.h"
+
+MMA7361L accel(p15, p16, p17, p25, p26, p24);
+
+int main() {
+    accel.setScale(MMA7361L::SCALE_6G); // 6g mode
+
+    while (true) {
+        printf("x = %5.3f, y = %5.3f, z = %5.3f\n",
+               accel.getAccelX(), accel.getAccelY(), accel.getAccelZ());
+        wait(1.0);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Buzzer.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Buzzer.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,15 @@
+#include "mbed.h"
+
+DigitalOut buzzer(p21);
+
+int main() {
+    while (true) {
+        for (int i = 0; i < 3; i++) {
+            buzzer = 1;
+            wait(0.05);
+            buzzer = 0;
+            wait(0.05);
+        }
+        wait(0.7);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 CanSat1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CanSat1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "MMA7361L.h"
+
+DigitalIn pressed(p20);
+MMA7361L accel(p15, p16, p17, p25, p26, p24);
+LocalFileSystem local("local");
+
+void logAccel(FILE *fp, MMA7361L& accel) {
+   char timestamp[32];
+
+   time_t seconds = time(NULL);
+   strftime(timestamp, sizeof(timestamp), "%X", localtime(&seconds));
+
+   fprintf(fp, "%s %5.3f %5.3f %5.3f %5.3f\n",
+           timestamp, accel.getAccel(),
+           accel.getAccelX(), accel.getAccelY(), accel.getAccelZ());
+}
+
+int main() {
+   accel.setScale(MMA7361L::SCALE_6G);
+   FILE *fp = fopen("/local/accel.txt", "w");
+
+    while (!pressed) {
+        logAccel(fp, accel);
+        wait(1.0);
+    }
+
+    fclose(fp);
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 CanSat2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CanSat2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+DigitalIn pressed(p20);
+
+BusOut leds(LED1, LED2, LED3, LED4);
+
+int main() {
+    for (int i = 0; !pressed; i = (i + 1) % 2)  {
+        leds = i;
+        wait(0.2);
+    }
+
+    leds = 15;
+    wait(1);
+
+    for (int i = 0; !pressed; i = (i + 1) % 4)  {
+        leds = 1 << i;
+        wait(0.5);
+        leds = 0;
+        wait(0.5);
+    }
+
+    leds = 15;
+    wait(1);
+    leds = 0;
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 CanSat3.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CanSat3.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "MMA7361L.h"
+
+DigitalIn pressed(p20);
+MMA7361L accel(p15, p16, p17, p25, p26, p24);
+LocalFileSystem local("local");
+BusOut leds(LED1, LED2, LED3, LED4);
+
+void logAccel(FILE *fp, MMA7361L& accel) {
+    char timestamp[32];
+
+    time_t seconds = time(NULL);
+    strftime(timestamp, sizeof(timestamp), "%X", localtime(&seconds));
+
+    fprintf(fp, "%s %5.3f %5.3f %5.3f %5.3f\n",
+            timestamp, accel.getAccel(),
+            accel.getAccelX(), accel.getAccelY(), accel.getAccelZ());
+}
+
+int main() {
+    for (int i = 0; !pressed; i = (i + 1) % 2)  {
+        leds = i;
+        wait(0.2);
+    }
+    leds = 15;
+    wait(1);
+
+    accel.setScale(MMA7361L::SCALE_6G);
+    FILE *fp = fopen("/local/accel.txt", "w");
+
+    for (int i = 0; !pressed; i = (i + 1) % 4) {
+        logAccel(fp, accel);
+
+        leds = 1 << i;
+        wait(0.5);
+        leds = 0;
+        wait(0.5);
+    }
+    
+    fclose(fp);
+
+    leds = 15;
+    wait(1);
+    leds = 0;
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Countdown1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Countdown1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+
+int main() {
+    myleds[0] = 1; myleds[1] = 1; myleds[2] = 1; myleds[3] = 1;
+    wait(1.0);
+    myleds[0] = 1; myleds[1] = 1; myleds[2] = 1; myleds[3] = 0;
+    wait(1.0);
+    myleds[0] = 1; myleds[1] = 1; myleds[2] = 0; myleds[3] = 1;
+    ...
+    wait(1.0);
+    myleds[0] = 0; myleds[1] = 0; myleds[2] = 0; myleds[3] = 0;
+    wait(0.2);
+    myleds[0] = 1; myleds[1] = 1; myleds[2] = 1; myleds[3] = 1;
+    wait(0.2);
+    myleds[0] = 0; myleds[1] = 0; myleds[2] = 0; myleds[3] = 0;
+    wait(0.2);
+    myleds[0] = 1; myleds[1] = 1; myleds[2] = 1; myleds[3] = 1;
+    ...
+    myleds[0] = 1; myleds[1] = 1; myleds[2] = 1; myleds[3] = 1;
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Countdown2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Countdown2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+
+void setMyLeds(bool arg0, bool arg1, bool arg2, bool arg3) {
+    myleds[0] = arg0;
+    myleds[1] = arg1;
+    myleds[2] = arg2;
+    myleds[3] = arg3;
+}
+
+int main() {
+    for (int i = 15; i > 0; i--) {
+        setMyLeds(i & 8, i & 4, i & 2, i & 1);
+        wait(1.0);
+    }
+
+    for (bool on = false;; on = !on) {
+        setMyLeds(on, on, on, on);
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Countdown3.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Countdown3.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,14 @@
+#include "mbed.h"
+
+BusOut myleds(LED4, LED3, LED2, LED1);
+
+int main() {
+    for (myleds = 15; myleds > 0; myleds = myleds - 1) {
+        wait(1.0);
+    }
+
+    for (;;) {
+        wait(0.2);
+        myleds = 15 - myleds;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 FileIO.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FileIO.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,10 @@
+#include "mbed.h"
+
+LocalFileSystem local("local");
+
+int main() {
+    FILE *fp = fopen("/local/out.txt", "w");
+
+    fprintf(fp, "Hello World!\n");
+    fclose(fp);
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Interrupt.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Interrupt.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,13 @@
+#include "mbed.h"
+
+DigitalOut myled(p5);
+InterruptIn switchEvent(p8);
+
+void switchPressed() {
+    myled = !myled;
+}
+
+int main() {
+    switchEvent.rise(switchPressed);
+    wait(60);
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,12 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,15 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+DigitalOut myled2(LED2);
+
+int main() {
+    while(1) {
+        myled = 1;
+        myled2 = 1;
+        wait(0.2);
+        myled = 0;
+        myled2 = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed3.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed3.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+int main() {
+    while(1) {
+        myled1 = 1;
+        myled2 = 1;
+        myled3 = 1;
+        myled4 = 1;
+        wait(0.2);
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 0;
+        myled4 = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed4.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed4.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+DigitalOut myleds[] = {myled1, myled2, myled3, myled4};
+
+int main() {
+    while(1) {
+        myleds[0] = 1;
+        myleds[1] = 1;
+        myleds[2] = 1;
+        myleds[3] = 1;
+        wait(0.2);
+        myleds[0] = 0;
+        myleds[1] = 0;
+        myleds[2] = 0;
+        myleds[3] = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed5.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed5.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+
+int main() {
+    while(1) {
+        myleds[0] = 1;
+        myleds[1] = 1;
+        myleds[2] = 1;
+        myleds[3] = 1;
+        wait(0.2);
+        myleds[0] = 0;
+        myleds[1] = 0;
+        myleds[2] = 0;
+        myleds[3] = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed6.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed6.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,16 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+
+int main() {
+    while(1) {
+        for (int i = 0; i < 4; i++) {
+            myleds[i] = 1;
+        }
+        wait(0.2);
+        for (int i = 0; i < 4; i++) {
+            myleds[i] = 0;
+        }
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed7.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed7.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+
+void setMyLeds(bool arg) {
+    for (int i = 0; i < 4; i++) {
+        myleds[i] = arg;
+    }
+}
+
+int main() {
+    while(1) {
+        setMyLeds(1);
+        wait(0.2);
+        setMyLeds(0);
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed8.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed8.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+
+void setMyLeds(bool arg0, bool arg1, bool arg2, bool arg3) {
+    myleds[0] = arg0;
+    myleds[1] = arg1;
+    myleds[2] = arg2;
+    myleds[3] = arg3;
+}
+
+int main() {
+    while(1) {
+        setMyLeds(1, 0, 1, 0);
+        wait(0.2);
+        setMyLeds(0, 1, 0, 1);
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MyLed9.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed9.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,12 @@
+#include "mbed.h"
+
+DigitalOut myled(p5);
+
+int main() {
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MySw1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MySw1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,10 @@
+#include "mbed.h"
+
+DigitalOut myled(p5);
+DigitalIn mysw(p8);
+
+int main() {
+    while(1) {
+        myled = mysw;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 MySw2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MySw2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+
+DigitalOut myled(p5);
+DigitalIn mysw(p8);
+
+int main() {
+    bool stateSW = false;
+    
+    while (true) {
+        if (mysw != stateSW) {
+            stateSW = !stateSW;
+            if (stateSW) {
+                myled = !myled;
+            }
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 PC.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PC.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,5 @@
+#include "mbed.h"
+
+int main() {
+    printf("Hello World!\n");
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 RTC1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,14 @@
+#include "mbed.h"
+
+int main() {
+    time_t seconds;
+    char buf[32];
+
+    seconds = (((2011 - 1969) * 365 + (2011 - 1968) / 4)
+               + 31 + 29 + 31 + 30 + 26) * 24 * 3600
+              + 15 * 3600 + 14 * 60;
+    set_time(seconds);
+    seconds = time(NULL);
+    strftime(buf, sizeof(buf), "%x %X", localtime(&seconds));
+    printf("mbed rtc = %s (timestamp = %d)\n", buf, seconds);
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 RTC2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+
+void printTime(int n) {
+    printf("\n");
+
+    time_t prev = time(NULL);
+    while (n > 0) {
+        time_t seconds = time(NULL);
+        if (prev != seconds) {
+            char buf[32];
+            strftime(buf, sizeof(buf), "%x %X", localtime(&seconds));
+            printf("%s\n", buf);
+            prev = seconds;
+            n--;
+        }
+    }
+}
+
+void adjustTime() {
+    int n1, n2, n3, n4, n5, n6;
+    struct tm t;
+
+    printf("\nEnter current time (yy/mm/dd hh:mm:ss)\n");
+
+    scanf("%d / %d / %d %d : %d : %d", &n1, &n2, &n3, &n4, &n5, &n6);
+    t.tm_sec = n6;
+    t.tm_min = n5;
+    t.tm_hour = n4;
+    t.tm_mday = n3;
+    t.tm_mon = n2 - 1;
+    t.tm_year = n1 + 100;
+
+    set_time(mktime(&t));
+}
+
+int main() {
+    if (time(NULL) == (time_t) -1) {
+        set_time(0);
+    }
+
+    printf("Adjust RTC - Enter t or T\n");
+
+    while (true) {
+        switch (getchar()) {
+            case 'T':
+                adjustTime();
+                break;
+            case 't':
+                printTime(5);
+                break;
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Temp1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Temp1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,11 @@
+#include "mbed.h"
+
+AnalogIn lm60(p20);
+
+int main() { 
+    while (true) {
+        float value = lm60;
+        printf("lm60 = %5.4f\n", value);
+        wait(1.0);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Temp2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Temp2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,12 @@
+#include "mbed.h"
+
+AnalogIn lm60(p20);
+
+int main() { 
+    while (true) {
+        float volts = 3.3 * lm60;
+        float temp = (volts - 0.424) / 0.00625;
+        printf("Temperature = %4.2f (%4.3fV)\n", temp, volts);
+        wait(1.0);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Volume1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Volume1.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,10 @@
+#include "mbed.h"
+
+AnalogIn volume(p20);
+PwmOut myled(p21);
+
+int main() {
+    while (true) {
+        myled = volume;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f309f06aeec7 Volume2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Volume2.cpp	Thu May 10 21:14:34 2012 +0000
@@ -0,0 +1,10 @@
+#include "mbed.h"
+
+AnalogIn volume(p20);
+PwmOut myled(p21);
+
+int main() {
+    while (true) {
+        myled = (exp(log(256.0) * volume) - 1) / 255;
+    }
+}
\ No newline at end of file