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
Diff: main.cpp
- Revision:
- 4:972778a8aca8
- Parent:
- 3:9d006b6e1d04
--- a/main.cpp	Sat Mar 27 13:19:00 2021 +0000
+++ b/main.cpp	Sat Apr 10 12:13:04 2021 +0000
@@ -15,25 +15,21 @@
 const int HIGH = 1; // Optional, but makes code more readable.
 const int LOW = 0; // Optional, but makes code more readable.
  
-AnalogIn analog_value(A0); 
+AnalogIn analog_value(A1); 
 DigitalOut led(LED1);
 PwmOut servo(D6);
 
 int main() {
     float value; // Value to be read and sent to serial port.
-    int i=0, angle;
     servo.period_ms(20);
-    
     printf("\nAnalogIn example\n");
     
     while(true) {
         value = analog_value.read(); // Read the analog input value (0 to 1)
         printf("Value = %f\n", value); // Send value as text via serial port.
-        printf("Value_int = %d\n", int(value*180)); // Send value as text via serial port.
-        angle = int(value*180);
+//        printf("Value_int = %d\n", int(value*180)); // Send value as text via serial port.
+        int angle = int(value*180);
         servo.pulsewidth_us(10*angle+500);
-        wait_ms(10);
-
 
         if (value > 0.5f) { // Activate built-in LED. The f is optional.
           led.write(HIGH);
@@ -43,16 +39,5 @@
         }
         printf("LED = %d\n", (int) led.read()); // Send LED state via serial. 
         wait(0.25); // 250 ms
-        
-//        for (i=0; i<=200; i++){
-//            servo.pulsewidth_us(10*i+500);
-//            wait_ms(10);
-//        }
-//        for (i=0; i<=200; i++){
-//            servo.pulsewidth_us(-10*i+2500);
-//            wait_ms(10);
-//        }
-        
-        
     }
 }