first mbed project

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Naoto_111
Date:
Wed May 14 08:01:22 2014 +0000
Parent:
2:3c83ffc5a61a
Commit message:
use analogout

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue May 13 15:52:46 2014 +0000
+++ b/main.cpp	Wed May 14 08:01:22 2014 +0000
@@ -2,14 +2,18 @@
 
 DigitalOut led[]= {LED1,LED2,LED3,LED4,LED3,LED2};
 Serial pc(USBTX,USBRX);//tx,rx
-
+AnalogOut led_y(p18);
+float f(int i)
+{
+    return i<4 ? (int)(3.3*i+0.5)/10.0 : (10-(int)(3.3*(i-3)+0.5))/10.0;
+}
 
 int main()
 {
-    pc.printf("LikWeeDayo");
     while(1) {
         for(int i=0; i<6; i=1+i) {
             led[i]=0;
+            led_y=f(i);
             led[(i+1)%6]=1;
             pc.printf("led[%d] is ON\r\n",(i+1)%6);
             wait(0.2);