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:
- 4:ba51736778e1
- Parent:
- 3:60722da62531
--- a/mover.cpp Fri Sep 07 03:42:26 2018 +0000
+++ b/mover.cpp Fri Sep 07 23:58:14 2018 +0000
@@ -40,7 +40,9 @@
void mover_ser(uint8_t motor, uint8_t pos){
int pulseX = coord2us(pos);
-
+ //int pulseX = 900;
+ //int pulseY = 1500;
+ // myServo1.pulsewidth_us(pulseX);
switch ( motor ) {
case 0x01:
@@ -72,7 +74,127 @@
}
}
-
+void mover_par(uint8_t pares, uint8_t dir){
+
+ switch ( pares ) {
+
+ case 0x01:
+ if(dir==0x01){
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ }else{
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ }
+ break;
+ case 0x02:
+ if(dir==0x01){
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ }else{
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ }
+ break;
+ case 0x03:
+ if(dir==0x01){
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ }else{
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ }
+ break;
+ case 0x04:
+ if(dir==0x01){
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ }else{
+ Servo1.pulsewidth_us(ARRIBA);
+ wait(0.5);
+ Servo2.pulsewidth_us(ATRAS);
+ wait(0.5);
+ Servo1.pulsewidth_us(ABAJO);
+ wait(0.5);
+ Servo2.pulsewidth_us(ADELANTE);
+ wait(0.5);
+ }
+ break;
+ default: break;
+}
+ }
+void centro(uint8_t pos_p){
+switch ( pos_p ) {
+
+ case 0x01:
+ Servo1.pulsewidth_us(CENTRO);
+ wait(1);
+ Servo2.pulsewidth_us(CENTRO);
+ wait(1);
+ break;
+ case 0x02:
+ Servo3.pulsewidth_us(CENTRO);
+ wait(1);
+ Servo4.pulsewidth_us(CENTRO);
+ wait(1);
+ break;
+ case 0x03:
+ Servo5.pulsewidth_us(CENTRO);
+ wait(1);
+ Servo6.pulsewidth_us(CENTRO);
+ wait(1);
+ break;
+ case 0x04:
+ Servo7.pulsewidth_us(CENTRO);
+ wait(1);
+ Servo8.pulsewidth_us(CENTRO);
+ wait(1);
+ break;
+ default: break;
+}
+ }
void init_servo()
{
Servo1.period_ms(20);
