Stap 27: Test alle motoren met Arduino - Autonomish
Dus is hier wat eenvoudige (maar lange) Arduino-code.
Het draait elke motor - voorwaartse en achterwaartse - snel en traag.
///////////////////////// ARDUINO ////////////////////////////
Richting lage = naar lichaam of doorsturen
Richting hoog = uit de buurt van lichaam of achterwaarts
int RightArmDir = 2;
int RightArmSpeed = 3;
int LeftArmDir = 4;
int LeftArmSpeed = 5;
int WaistDir = 7;
int WaistSpeed = 6;
int RightWheelDir = 8;
int RightWheelSpeed = 9;
int LeftWheelDir = 12;
int LeftWheelSpeed = 10;
int Slow = 20;
int Fast = 40;
int t1 = 500;
int t2 = 100;
VOID Setup {}
pinMode (RightArmDir, uitvoer);
pinMode (RightArmSpeed, uitvoer);
pinMode (LeftArmDir, uitvoer);
pinMode (LeftArmSpeed, uitvoer);
pinMode (WaistDir, uitvoer);
pinMode (WaistSpeed, uitvoer);
pinMode (RightWheelDir, uitvoer);
pinMode (RightWheelSpeed, uitvoer);
pinMode (LeftWheelDir, uitvoer);
pinMode (LeftWheelSpeed, uitvoer);
Serial.begin(9600);
}
void loop {}
BASISTESTS / /
Serial.println ("BASISTESTS");
De rechterarm test
Serial.println ("rechterarm");
Rechterarm omhoog
Serial.println("up");
digitalWrite (RightArmDir, hoge);
digitalWrite (RightArmSpeed, Slow);
vertraging (t1);
digitalWrite(RightArmSpeed,Fast);
vertraging (t2);
digitalWrite(RightArmSpeed,Slow);
delay(T1);
digitalWrite (RightArmSpeed, 0);
delay(T1);
Rechterarm naar beneden
Serial.println("down");
digitalWrite (RightArmDir, laag);
digitalWrite (RightArmSpeed, Slow);
vertraging (t1);
digitalWrite (RightArmSpeed, Fast);
vertraging (t2);
digitalWrite (RightArmSpeed, Slow);
delay(T1);
digitalWrite (RightArmSpeed, 0);
delay(T1);
Test linkerarm
Serial.println ("linker Arm");
Linker Arm omhoog
Serial.println("up");
digitalWrite (LeftArmDir, hoge);
digitalWrite (LeftArmSpeed, Slow);
vertraging (t1);
digitalWrite (LeftArmSpeed, Fast);
vertraging (t2);
digitalWrite (LeftArmSpeed, Slow);
vertraging (t1);
digitalWrite (LeftArmSpeed, 0);
delay(T1);
Linkerarm naar beneden
Serial.println("down");
digitalWrite (LeftArmDir, laag);
digitalWrite (LeftArmSpeed, Slow);
vertraging (t1);
digitalWrite (LeftArmSpeed, Fast);
vertraging (t2);
digitalWrite(LeftArmSpeed,Slow);
delay(T1);
digitalWrite (LeftArmSpeed, 0);
delay(T1);
Test taille
Serial.println("waist");
Bukken
Serial.println("down");
digitalWrite (WaistDir, hoge);
digitalWrite (WaistSpeed, Slow);
vertraging (t1);
digitalWrite (WaistSpeed, Fast);
vertraging (t2);
digitalWrite (WaistSpeed, Slow);
delay(T1);
digitalWrite (WaistSpeed, 0);
delay(T1);
Buig omhoog
Serial.println("up");
digitalWrite (WaistDir, laag);
digitalWrite (WaistSpeed, Slow);
vertraging (t1);
digitalWrite (WaistSpeed, Fast);
vertraging (t2);
digitalWrite (WaistSpeed, Slow);
delay(T1);
digitalWrite (WaistSpeed, 0);
delay(T1);
Het juiste wiel test
Serial.println ("juiste wiel");
Doorsturen van het juiste wiel '
Serial.println("foward");
digitalWrite (RightWheelDir, hoge);
digitalWrite (RightWheelSpeed, Slow);
vertraging (t1);
digitalWrite (RightWheelSpeed, Fast);
vertraging (t2);
digitalWrite (RightWheelSpeed, Slow);
delay(T1);
digitalWrite (RightWheelSpeed, 0);
delay(T1);
Juiste wiel achteruit
Serial.println("backward");
digitalWrite (RightWheelDir, laag);
digitalWrite (RightWheelSpeed, Slow);
vertraging (t1);
digitalWrite (RightWheelSpeed, Slow);
vertraging (t2);
digitalWrite (RightWheelSpeed, Slow);
vertraging (t1);
digitalWrite (RightWheelSpeed, 0);
delay(T2);
Test linker wiel
Serial.println ("linker wiel");
Linker wiel doorsturen
Serial.println("foward");
digitalWrite (LeftWheelDir, hoge);
digitalWrite (LeftWheelSpeed, Slow);
vertraging (t1);
digitalWrite (LeftWheelSpeed, Slow);
vertraging (t2);
digitalWrite (LeftWheelSpeed, Slow);
delay(T1);
digitalWrite (LeftWheelSpeed, 0);
delay(T1);
Linker wiel terug
Serial.println("backward");
digitalWrite (LeftWheelDir, laag);
digitalWrite (LeftWheelSpeed, Slow);
vertraging (t1);
digitalWrite (LeftWheelSpeed, Slow);
vertraging (t2);
digitalWrite(LeftWheelSpeed,Slow);
delay(T1);
digitalWrite (LeftWheelSpeed, 0);
delay(T1);
FANCY TESTS / /
Serial.println ("FANCY TESTS");
Raken vloer
Aanraking van de hemel
Uitgangspositie
Draai links
Draai rechts
Gaan doorsturen
Achterwaarts gaan
Robot dans
Serial.println("REPEAT...");
}