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.
Dependencies: mbed
Diff: motor.cpp
- Revision:
- 4:ab3a8a7a0fcf
- Parent:
- 3:6898c5bd7fef
- Child:
- 5:94b196231ecd
--- a/motor.cpp Mon Aug 20 08:51:01 2018 +0000
+++ b/motor.cpp Mon Aug 20 09:12:05 2018 +0000
@@ -103,18 +103,26 @@
for (v=0; v<10; v++){ // for each 1 unit of speed v
if (SValue < 0xFF) { // check if speed less than max
SValue++;
- }
- for(ch=1; ch<3; ch++){ // each channel
+ }
+ for(ch=1; ch<3; ch++){ // each big motor
motorSpiSend(ch,SValue); // increase speed by 1 unit
wait(0.01); // 2nd motor increases .01s after 1st motor
}
+ for(ch=5; ch<9; ch++){ // each small motor
+ motorSpiSend(ch,SValue); // increase speed by 1 unit
+ wait(0.01); // 2nd motor increases .01s after 1st motor
+
}
}
void motorStop(){
int ch, v;
for (v=SValue; v>0; v--){ // for each 1 unit of speed v
- for(ch=1; ch<3; ch++){ // each channel
+ for(ch=1; ch<3; ch++){ // each big motor
+ motorSpiSend(ch,v); // decrease speed by 1 unit
+ wait(0.01); // 2nd motor decreses .01s after 1st motor
+ }
+ for(ch=5; ch<9; ch++){ // each small motor
motorSpiSend(ch,v); // decrease speed by 1 unit
wait(0.01); // 2nd motor decreses .01s after 1st motor
}