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: main.cpp
- Revision:
- 0:8ba886befbee
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Oct 28 14:17:00 2018 +0000
@@ -0,0 +1,28 @@
+#Control Servo position with PWM
+
+#include "mbed.h"
+PwmOut servo(p7);
+int main() {
+ for(float i = 0; i <= 1; i = i + 0.25)
+ {
+ servo = i;
+ wait(0.02);
+ }
+ while(1);
+}
+
+#LDR
+
+#include "mbed.h"
+DigitalOut myled(LED1);
+AnalogIn ldr(p20);
+Serial pc(USBTX, USBRX);
+PwmOut servo(p5);
+int main() {
+ servo.period_ms(20);
+ while(1)
+ { pc.printf("%.2f\n\r", ldr*180);
+ servo.pulsewidth_us(1500+ldr*1500);
+ wait(0.1);
+ }
+}