test

Dependencies:   Servo mbed

Fork of Servo by Frank Girald

Files at this revision

API Documentation at this revision

Comitter:
elriru
Date:
Fri May 11 11:26:00 2018 +0000
Parent:
2:115ddb84b970
Commit message:
test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 26 13:46:52 2017 +0000
+++ b/main.cpp	Fri May 11 11:26:00 2018 +0000
@@ -1,21 +1,30 @@
 #include "mbed.h"
 #include "Servo.h"
+DigitalOut led1(LED1);
+InterruptIn button(D0);
+Servo servomotor(D5); // PIN PWM
+Serial pc(SERIAL_TX, SERIAL_RX); 
 
-Serial rs232(USBTX, USBRX);
-Servo servomotor(PTE29); // PIN PWM
-int grados,k;
+
+void button_pressed()
+{
+    led1=1;
+    servomotor=1;
+    
+    
+}
+
+void button_released()
+{
+    led1=0;
+    servomotor=0;
+    
+}
+
 
 int main()
-{
-    rs232.baud(9600);
-    while(1) {
-        grados=0;k=0;
-        for(float i=0; i<1.0; i += 0.08333) { // 12 pasos de 15° (0 a 180° entre 0 y 1.0 mseg: 0.08333mseg por paso)
-            servomotor = i;
-            wait(0.5);
-            grados=k*15;
-            rs232.printf("%d \r\n",grados); //Visualiza avance cada 15°
-            ++k;
-        }
-    }
+
+{   
+    button.fall(&button_pressed); // Change led delay
+    button.rise(&button_released); // Change led
 }
--- a/mbed.bld	Thu Oct 26 13:46:52 2017 +0000
+++ b/mbed.bld	Fri May 11 11:26:00 2018 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file