The problem is that I cannot find any very simple guide to programme them, we just want to make the robot go forward a given distance, turn a certain number of degrees etc.
Thanks for breaking things down somewhat tkbyd,
I realise that I am going to have to take very small steps in order to bring this project to fruition.
I'll let you know when I complete step 1.
Using a treaded base you won't get a lot of accuracy in turns even with an encoder (though the encoder won't hurt if it's there). The agility in turns for a tank-type robot depends on the surface it's going over. The rubber treads used on this kit -- and many like it -- is very compliant, meaning it literally sticks to hard surfaces. That means it may skate unpredictably if the tread simply skips over the surface in turns.
Over carpet and other slippery surfaces the treads won't skate, but the amount of turn is very hard to determine.
You can still play and experiment using the kit you have, but the turns will seldom be as accurate as what you may be looking for. Instead of worrying about odometry, maybe apply a different type of project. A line or wall follower doesn't need encoders, for example.
Thks for the info robtillaart, I think that I have bitten off a little more than I can chew
You are probably right Gordon a line or wall following robot probably would of been more sensible but I'm not good at sensible =(
I'm not good at quitting either, so I'm going to try and continue as far as I can (probably not very far), whilst starting another project in paralelle.
This is the code I have so far:
// Wheel encoder/LED/Motor #define LED 13 //pin for LED #define ECOD 7 //pin for encoder pulse
int transistorPin = 11; // sends current to transistor/motor
int val = 0; // store state of encoder
void setup(){
pinMode(LED, OUTPUT); //led is output
pinMode(transistorPin, OUTPUT); // motor is output
pinMode(ECOD, INPUT); //encoder is input
}
void loop()
{
val = digitalRead(ECOD); //read value of encoder and store it
if (val == HIGH)
{
digitalWrite(LED, HIGH); // turn led on during pulse
digitalWrite(transistorPin, HIGH); //turn Motor on during pulse
} else {
digitalWrite(LED, LOW); // turn led off when pulse stops
digitalWrite(transistorPin, LOW); // turn motor off when pulse stops
}
}
So at the moment when I turn the encoder it turns the motor and Led on and off (at least if I move it very slowely).
Now I need to get it to count the pulses and turn off after a predifined number?
I did a nice little schematic to show the wiring but with no web space I don't seem to be able to post it =( If anyone where interested I'll e-mail it.