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
Revision 3:e43babb84ff3, committed 2018-09-09
- Comitter:
- MigueAut
- Date:
- Sun Sep 09 01:02:43 2018 +0000
- Parent:
- 2:6e6157daf08b
- Commit message:
- 3 MOTORES
Changed in this revision
diff -r 6e6157daf08b -r e43babb84ff3 main.cpp
--- a/main.cpp Wed Sep 05 20:31:54 2018 +0000
+++ b/main.cpp Sun Sep 09 01:02:43 2018 +0000
@@ -20,6 +20,8 @@
read_cc=read_command();
switch (read_cc) {
case 0x01: moving(); break;
+ case 0x02: moving(); break;
+ case 0x03: moving(); break;
default: debug_m("error de comando. \n");break ;
}
}
@@ -35,7 +37,7 @@
char intc=command.getc();
- while(intc != '<')
+ while(intc != '<' )
intc=command.getc();
return command.getc();
}
@@ -52,7 +54,7 @@
char nmotor=command.getc();
char grados=command.getc();
- debug_m("SE MOEVE EL MOTOR %d, EN %d GRADOS ..\n", nmotor,grados );
+ debug_m("SE MUEVE EL MOTOR %d, EN %d GRADOS ..\n", nmotor,grados );
char endc=command.getc();
mover_ser(nmotor,grados);
diff -r 6e6157daf08b -r e43babb84ff3 mover.cpp
--- a/mover.cpp Wed Sep 05 20:31:54 2018 +0000
+++ b/mover.cpp Sun Sep 09 01:02:43 2018 +0000
@@ -18,8 +18,8 @@
int coord2us(float coord)
{
- if(0 <= coord <= MAXPOS)
- return int(750+coord*1900/50);// u6
+ if(0 <= coord <= 180)
+ return int(750+coord*1900/180);// u6
return 750;
}
@@ -28,14 +28,20 @@
-void mover_ser(uint8_t motor, uint8_t pos){
+void mover_ser(uint8_t nmotor, uint8_t grados){
+ int pulseX = coord2us(grados);
+ switch(nmotor){
+ case 0x01:
+ myServo1.pulsewidth_us(pulseX);
+ break;
+ case 0x02:
+ myServo2.pulsewidth_us(pulseX);
+ break;
+ case 0x03:
+ myServo3.pulsewidth_us(pulseX);
+ break;}
+}
- int pulseX = coord2us(pos);
-
- myServo1.pulsewidth_us(pulseX);
-
-
-}
void init_servo()
{
diff -r 6e6157daf08b -r e43babb84ff3 mover.h --- a/mover.h Wed Sep 05 20:31:54 2018 +0000 +++ b/mover.h Sun Sep 09 01:02:43 2018 +0000 @@ -11,7 +11,7 @@ void init_servo(); void draw(); void nodraw(); -void mover_ser(uint8_t motor, uint8_t pos); +void mover_ser(uint8_t nmotor, uint8_t grados);
