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 01-04EntregaPrimerCorte by
Diff: mover.cpp
- Revision:
- 2:10956b8ceffb
- Parent:
- 1:526bdd5faa37
- Child:
- 3:60722da62531
diff -r 526bdd5faa37 -r 10956b8ceffb mover.cpp
--- a/mover.cpp Tue Sep 04 02:15:49 2018 +0000
+++ b/mover.cpp Thu Sep 06 18:05:07 2018 +0000
@@ -4,9 +4,14 @@
#include "math.h"
-PwmOut myServo1(PB_3);
-PwmOut myServo2(PB_4);
-PwmOut myServo3(PB_5);
+PwmOut Servo1(PA_11);
+PwmOut Servo2(PA_11);
+PwmOut Servo3(PA_11);
+PwmOut Servo4(PA_11);
+PwmOut Servo5(PA_11);
+PwmOut Servo6(PA_11);
+PwmOut Servo7(PA_11);
+PwmOut Servo8(PA_11);
uint8_t ss_time=50; // tiempo de espera para moverse 1 mm en microsegundos
@@ -30,18 +35,52 @@
void mover_ser(uint8_t motor, uint8_t pos){
- int pulseX = coord2us(pos);
-
- myServo1.pulsewidth_us(pulseX);
-
+ //int pulseX = coord2us(pos);
+ int pulseX = 900;
+ int pulseY = 1900;
+ // myServo1.pulsewidth_us(pulseX);
+ switch ( motor ) {
+
+ case 0x01:
+ Servo1.pulsewidth_us(pulseX);
+ break;
+ case 0x02:
+ Servo2.pulsewidth_us(pulseY);
+ break;
+ case 0x03:
+ Servo3.pulsewidth_us(pulseX);
+ break;
+ case 0x04:
+ Servo4.pulsewidth_us(pulseX);
+ break;
+ case 0x05:
+ Servo5.pulsewidth_us(pulseX);
+ break;
+ case 0x06:
+ Servo6.pulsewidth_us(pulseX);
+ break;
+ case 0x07:
+ Servo7.pulsewidth_us(pulseX);
+ break;
+ case 0x08:
+ Servo8.pulsewidth_us(pulseX);
+ break;
+
+ default: break;
+}
}
void init_servo()
{
- myServo1.period_ms(20);
- myServo2.period_ms(20);
- myServo3.period_ms(20);
+ Servo1.period_ms(20);
+ Servo2.period_ms(20);
+ Servo3.period_ms(20);
+ Servo4.period_ms(20);
+ Servo5.period_ms(20);
+ Servo6.period_ms(20);
+ Servo7.period_ms(20);
+ Servo8.period_ms(20);
+
+}
-
-}
\ No newline at end of file
