Go Down

Topic: Wheel Encoders for complet newbies (Read 1 time) previous topic - next topic


Thks for the info robtillaart, I think that I have bitten off a little more than I can chew  :smiley-sweat:

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.

Thanks again for your interest.

Go Up