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:
- 3:e43babb84ff3
- Parent:
- 1:526bdd5faa37
--- 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()
{
