test

Dependencies:   Servo mbed

Fork of Servo by Frank Girald

Revision:
3:e862bc753f48
Parent:
2:115ddb84b970
--- 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
 }