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.
Fork of HW5_Servo by
main.cpp
00001 // Hello World to sweep a servo through its full range 00002 00003 #include "mbed.h" 00004 #include "Servo.h" 00005 00006 00007 #define DEBUG 0 00008 00009 DigitalIn toggleSwitch(D3); 00010 //debugging Analog in 00011 AnalogIn ldr0(A5); 00012 PwmOut servoDriver(D2); 00013 Servo myservo(D2); //change digital pin here 00014 00015 00016 Serial pc(USBTX, USBRX); 00017 int main() { 00018 //myservo.position(270.0f); 00019 myservo.calibrate(.0006, 120.0); 00020 bool servoLogic = 0; 00021 00022 while(1){ 00023 if (toggleSwitch == 1) 00024 //if (ldr0.read() > 0.7) 00025 servoLogic = 1; 00026 else 00027 servoLogic = 0; 00028 //recieve_data(ServoLogic); 00029 if (servoLogic) 00030 { 00031 myservo = 0.0f; 00032 } 00033 else{ 00034 00035 myservo = 1.0f; 00036 } 00037 //For debugging purposes 00038 #if DEBUG 00039 printf("%f\n\r",ldr0.read()); 00040 #endif 00041 wait(.2); 00042 } 00043 }
Generated on Wed Aug 10 2022 00:28:23 by
1.7.2
