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 ArduMotoShield by
Revision 1:1c712818d82a, committed 2015-12-09
- Comitter:
- NorNick
- Date:
- Wed Dec 09 04:08:22 2015 +0000
- Parent:
- 0:72e45c332025
- Commit message:
- For Finish
Changed in this revision
| ArduMotoShield.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ArduMotoShield.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ArduMotoShield.cpp Sat Nov 08 15:44:22 2014 +0000
+++ b/ArduMotoShield.cpp Wed Dec 09 04:08:22 2015 +0000
@@ -22,10 +22,12 @@
#define LOW 0
#define HIGH 1
-DigitalOut inApin(D12, LOW); //direction control for motor outputs 1 and 2 is on digital pin 12
-DigitalOut inBpin(D13, LOW); //direction control for motor outputs 3 and 4 is on digital pin 13
+//DigitalOut inApin(D12, LOW); //direction control for motor outputs 1 and 2 is on digital pin 12
+//DigitalOut inBpin(D13, LOW); //direction control for motor outputs 3 and 4 is on digital pin 13
+BusOut inApin(D11,D12);
+BusOut inBpin(D13,D14);
PwmOut pwmApin(D3); //PWM control for motor outputs 1 and 2 is on digital pin 3
-PwmOut pwmBpin(D11); //PWM control for motor outputs 3 and 4 is on digital pin 11
+PwmOut pwmBpin(D5); //PWM control for motor outputs 3 and 4 is on digital pin 11
bool isSetup=false;
@@ -54,57 +56,72 @@
// Basic ArduMotoShield operations
-void ArduMotoShield::forward() //full speed forward
+void ArduMotoShield::forward(float A_PWM,float B_PWM) //full speed forward
{
if(!isSetup) setup();
- inApin.write(LOW);
- inBpin.write(LOW);
- pwmApin.write(MAXPWM);
- pwmBpin.write(MAXPWM);
- printf("Forward\n");
+ //inApin.write(LOW);
+ //inBpin.write(LOW);
+
+ inApin=1;
+ inBpin=1;
+ pwmApin.write(A_PWM);//(MAXPWM);
+ pwmBpin.write(B_PWM);//(MAXPWM);
+ //printf("Forward : %.2f\n",AnaPWM);
}
-void ArduMotoShield::backward() //full speed backward
+void ArduMotoShield::backward(float A_PWM,float B_PWM) //full speed backward
{
if(!isSetup) setup();
- inApin.write(HIGH);
- inBpin.write(HIGH);
- pwmApin.write(MAXPWM);
- pwmBpin.write(MAXPWM);
- printf("Backward\n");
+ //inApin.write(HIGH);
+ //inBpin.write(HIGH);
+
+ inApin=2;
+ inBpin=2;
+ pwmApin.write(A_PWM);//(MAXPWM);
+ pwmBpin.write(B_PWM);//(MAXPWM);
+ //printf("Backward\n");
+}
+
+void ArduMotoShield::right(float A_PWM,float B_PWM)
+{
+ if(!isSetup) setup();
+
+ //inApin.write(HIGH);
+ //inBpin.write(LOW);
+
+ inApin=1;
+ inBpin=2;
+ pwmApin.write(A_PWM);//(MAXPWM);
+ pwmBpin.write(B_PWM);//(MAXPWM);
+ //printf("Right\n");
+}
+
+void ArduMotoShield::left(float A_PWM,float B_PWM)
+{
+ if(!isSetup) setup();
+
+ //inApin.write(LOW);
+ //inBpin.write(HIGH);
+
+ inApin=2;
+ inBpin=1;
+ pwmApin.write(A_PWM);//(MAXPWM);
+ pwmBpin.write(B_PWM);//(MAXPWM);
+ //printf("Left\n");
}
void ArduMotoShield::stop()
{
if(!isSetup) setup();
- inApin.write(LOW);
- inBpin.write(LOW);
+ //inApin.write(LOW);
+ //inBpin.write(LOW);
+
+ inApin=0;
+ inBpin=0;
pwmApin.write(0.0f);
pwmBpin.write(0.0f);
- printf("Stop\n");
-}
-
-void ArduMotoShield::right()
-{
- if(!isSetup) setup();
-
- inApin.write(HIGH);
- inBpin.write(LOW);
- pwmApin.write(MAXPWM);
- pwmBpin.write(MAXPWM);
- printf("Right\n");
-}
-
-void ArduMotoShield::left()
-{
- if(!isSetup) setup();
-
- inApin.write(LOW);
- inBpin.write(HIGH);
- pwmApin.write(MAXPWM);
- pwmBpin.write(MAXPWM);
- printf("Left\n");
-}
+ //printf("Stop\n");
+}
\ No newline at end of file
--- a/ArduMotoShield.h Sat Nov 08 15:44:22 2014 +0000
+++ b/ArduMotoShield.h Wed Dec 09 04:08:22 2015 +0000
@@ -24,10 +24,10 @@
static void setVoltages(float vin, float vmaxmotor);
static void stop();
- static void forward();
- static void backward();
- static void left();
- static void right();
+ static void forward(float A_PWM,float B_PWM);
+ static void backward(float A_PWM,float B_PWM);
+ static void left(float A_PWM,float B_PWM);
+ static void right(float A_PWM,float B_PWM);
private:
static void setup();
};
