ARM Shanghai IoT Team (Internal) / Mbed 2 deprecated AnalogOutClassDemo_JacobShi

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
shiyilei
Date:
Tue Oct 21 15:22:55 2014 +0000
Parent:
4:6c49a5b891dc
Commit message:
use the Analogout class to generate a rectangle wave period :1S dutycycle:50%

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 22 20:19:09 2014 +0000
+++ b/main.cpp	Tue Oct 21 15:22:55 2014 +0000
@@ -1,13 +1,22 @@
+/**********************************************
+*file:rectangle wave generation
+*Creator:JacobShi
+*Time :2014/10/17
+*Description: use the analogout class
+*to generate a rectangle wave
+*period :1s and the dutycycle:0.5 
+***********************************************/
 #include "mbed.h"
- 
-AnalogOut signal(PTE30); // change this to match your board
+AnalogOut pin(p18);
 
-// ramp up the output in 10% incriments, drop to zero, repeat
-int main() {
-    while(1) {
-        for(float i=0.0; i<1.0; i+=0.1) {
-            signal = i;
-            wait(0.1);
-        }      
-    }
+int main(void)
+{
+    while(1)
+    {
+        pin=1;
+        wait(0.5);
+        pin=0;
+        wait(0.5);
+    }   
+
 }
\ No newline at end of file