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.
Dependencies: mbed
Revision 5:093723e0eea2, committed 2014-10-21
- 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