varying speed with motor shield

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

varying speed with motor shield

Postby Puck » Thu Feb 07, 2013 10:55 am

I'm using the Adafruit motor shield to control two brushed motors for propulsion on a voice controlled robot. I want to be able to vary the speed, example: "ahead full", "ahead one third" etc, for which I would designate in the code appropriate numbers between 0 and 255, but this would be done in the loop portion of the code where I define the various functions. example:

void aheadOneThird(){
motor1.setSpeed(85);
motor2.setSpeed(85);
motor1.run(FORWARD);
motor2.run(FORWARD);
delay(1000); //run time before rechecking sensors and command changes
}

void aheadFull(){
motor1.setSpeed(255);
motor2.setSpeed(255);
motor1.run(FORWARD);
motor2.run(FORWARD);
delay(1000);
}

Would this work or must setSpeed be done in setup? If it must be done in setup, is this number changeable (outside of changing it in the IDE, recompiling and reloading it) if it's in the setup portion of the code? Guidance greatly appreciated. Normally I would just try it, but I'm away from home and do not have access to my boards at the moment.

regards, Richard
Puck
 
Posts: 1
Joined: Wed Sep 21, 2011 5:03 pm



Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: No registered users and 5 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]