User:1sfoerster/enes100/Tri-BotHack/EncoderTest

/* Program to test encoders of WowWee Tribot Based upon the button example program

//first define constants const int buttonPin = 6;    // the number of the pushbutton pin const int ledPin = 13;      // the number of the LED pin int buttonState = 0;        // variable for reading the pushbutton status

void setup { // initialize the serial communications: Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the motor encoder as input: pinMode(buttonPin, INPUT); // initialize the motor control output button pinMode(12, OUTPUT); //yellow wire to motor enable 1 }

void loop{ // read the state of the motor encoder buttonState = digitalRead(buttonPin); digitalWrite(12, HIGH);  // turn motor on

// check if the encoder is high // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); Serial.print("high"); }  else { // turn LED off: digitalWrite(ledPin, LOW); Serial.print("low"); } delay(2000);              // wait two seconds digitalWrite(12, LOW);   // set the LED off delay(2000);             // wait for two seconds }