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.
Revision 43:bda92a299378, committed 2019-06-02
- Comitter:
- gorazdko
- Date:
- Sun Jun 02 08:52:41 2019 +0000
- Parent:
- 42:bcfaadc319d3
- Child:
- 44:50aa0a0d1222
- Commit message:
- OK
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Sun Jun 02 08:52:41 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- a/main.cpp Thu Jun 22 09:00:02 2017 +0100
+++ b/main.cpp Sun Jun 02 08:52:41 2019 +0000
@@ -1,12 +1,92 @@
#include "mbed.h"
+//Program to 'sweep' test a 'standard RC type servo
+//Define some parameters using compiler directive '#define'
+//Check Servo DATA if 0.75ms to 2.25ms then use min=750 and max=2250
+//NB be values in microseconds (Following are generic values)
+#define MID 1500
+#define MIN 544
+#define MAX 2400
+#define STEP 50
+//Time delay between steps in milliseconds
+#define TIME 20 //100
+
-DigitalOut led1(LED1);
+#define DELTA 50
+
+DigitalOut myLed(LED1);
+DigitalIn myButton(USER_BUTTON);
+
+PwmOut myServo(D3);
+
+
+
-// main() runs in its own thread in the OS
+ void motor_on(void)
+ {
+
+ //myServo.period_ms(20);
+ myServo.pulsewidth_us(MID); //NB in microseconds
+
+ }
+
+ void motor_off(void)
+ {
+ myServo.pulsewidth_us(MIN+2*DELTA); //NB in microseconds
+ }
+
+
+
int main() {
- while (true) {
- led1 = !led1;
- wait(0.5);
+
+ wait(3); // if (myButton)
+
+
+ while (0)
+ {
+ for (int i=0; i<1000;i++)
+ {
+ wait_ms(20);
+ motor_on();
+ }
+
+ for (int i=0; i<1000;i++)
+ {
+ wait_ms(20);
+ motor_off();
+ }
+
+ }
+
+
+ while (1)
+ {
+
+ for (int i=0; i<50*3; i++)
+ {
+ //myServo.period_ms(20);
+ myServo.pulsewidth_us(MIN); //NB in microseconds
+ wait_ms(TIME);
}
-}
-
+
+ for (int i=0; i<50*3; i++)
+ {
+ //myServo.period_ms(20);
+ myServo.pulsewidth_us(MID); //NB in microseconds
+ wait_ms(TIME);
+ }
+
+
+ }
+ /*
+ while(true) {
+ for (int i=MIN;i<=MAX;i+=STEP){
+ myServo.pulsewidth_us(i);
+ wait_ms(TIME);
+ }
+ for (int i=MAX;i>=MIN;i-=STEP){
+ myServo.pulsewidth_us(i);
+ wait_ms(TIME);
+ }
+ */
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os-example-blinky-LIGHTNING.lib Sun Jun 02 08:52:41 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST/code/mbed-os-example-blinky/#bcfaadc319d3