The situation:In march I have to present a work for school.. it's named 'robotics for dummies'. Using the arduino I want to controll a RC-model car (the RC part replaced by the arduino and some other electronics). To keep it simple, I'm only using 3 microswitches (2 in front, and 1 in the back).
The problem:I don't have the arduino YET! It will arrive in february. So I'm very short in time...
I've read a couple of tutorials and I'm already trying to make the program before I have the arduino.
But I might need some help since I can't test the program.
I'll translate a few comments from dutch to english. But if there is someone that speaks dutch, prepared to help me I would be verry happy!
The code:/*
* RC-auto Versie 0.1
* Tokesnugerd - Eindwerk Salco Haasrode '07/'08
*
* Dit programma moet de auto in staat stellen om door middel -> description what the program should do
* van 3 druksensoren rond te rijden zonder vast te steken. -> description what the program should do
*/
int Slv = #pin; // Pin where the front left switch is connected to
int Srv = #pin; // Pin where the front right switch is connected to
int Sa = #pin; // Pin where the rear switch is connected to
void setup() {
Serial.begin(9600); // Prepare serial
pinMode(Slv, INPUT); // Slv is input
pinMode(Srv, INPUT); // Srv is input
pinMode(Sa, INPUT); // Sa is input
Serial.println("Ik start het programma!"); // Says that program is starting
}
void BOTSlv() {
Serial.println("Ik ben links vanvoor gebotst!"); // Send message that there has been a collision front left
}
void BOTSrv() {
Serial.println("Ik ben rechts vanvoor gebotst!"); // Send message that there has been a collision front right
}
void BOTSa() {
Serial.println("Ik ben rechts vanachter gebotst!"); // Send message that there has been a collision rear
}
void loop() {
if (digitalRead(Slv) == LOW){ // front left collision
BOTSlv();
}
if (digitalRead(Srv) == LOW){ // front right collision
BOTSrv();
}
if (digitalRead(Sa) == LOW){ // rear collision
BOTSa();
}
}
That's all.. as you can see there isn't much about it.. but I want to be sure that the basics aren't full of errors!
May I post here another version when that one is completed ?
Thanks!!!!
Toke