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: generador.cpp
- Revision:
- 0:5267fffc245f
diff -r 000000000000 -r 5267fffc245f generador.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/generador.cpp Tue Sep 02 21:06:24 2014 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+AnalogOut Aout(p18);
+DigitalIn In(p10);
+DigitalIn In2(p11);
+DigitalIn In3(p12);
+PwmOut PWM1(p21); //create a PWM output called PWM1 on pin 21
+float i;
+
+
+int main() {
+ while(1) {
+ if (In==1) {
+
+ for (i=0;i<2;i=i+0.05) {
+ Aout=0.5+0.5*sin(i*3.14159); // Compute the sine value,+ half the range
+ wait(.01);// Controls the sine wave period
+ }
+ }
+
+ if (In2==1){
+ for (i=0;i<1;i=i+0.1){ // i is incremented in steps of 0.1
+ Aout=i;
+ wait(0.001); // wait 1 millisecond
+ }
+ }
+ if (In3==0){
+ PWM1.period(0.010); // set PWM period to 10 ms
+ PWM1=0.5; // set duty cycle to 50%
+}
+
+ }
+}