Compile error : 'OUTPUT' was not declared in this scope

void AFMotorController::enable(void) {
// setup the latch
/*
LATCH_DDR |= _BV(LATCH);
ENABLE_DDR |= _BV(ENABLE);
CLK_DDR |= _BV(CLK);
SER_DDR |= _BV(SER);
*/
pinMode(MOTORLATCH, OUTPUT);
pinMode(MOTORENABLE, OUTPUT);
pinMode(MOTORDATA, OUTPUT);
pinMode(MOTORCLK, OUTPUT);

latch_state = 0;

latch_tx(); // "reset"

//ENABLE_PORT &= ~_BV(ENABLE); // enable the chip outputs!
digitalWrite(MOTORENABLE, LOW);
}

Did I include enough code? I am using an Arduino for the first time. I bought a book that described how to build Linus, a line-following robot. The robot is built and I tried to download and compile the code but I get this error message. The line "pinMode {MOTORLATCH, OUTPUT}; line is highlighted. The site for the code is

I figured out how to include AFMotor.cpp and AFMotor.h in the sketch, I think. They are visible from tabs in the same window of my sketch. What am I doing wrong? Thanks!!

If you are using arduino 1.0, you need to change:
#import <WProgram.h>
To:
#import <Arduino.h>

There is one such change required at the top of the AFMotor.cpp file.

I figured it out. In addition to updating that line, I hab the libraries in the wrong place. Thank you so much!! One more question, though. This robot uses an IR emitter / detector pair to sense a black line, but it's "quirky" and veers way off and then tried to correct itself. I tried to view the sensors output in the serial monitor to better calibrate it, but the data stream is far too fast to read. Am I doing it wrong?

rocketman247:
I figured it out. In addition to updating that line, I hab the libraries in the wrong place. Thank you so much!! One more question, though. This robot uses an IR emitter / detector pair to sense a black line, but it's "quirky" and veers way off and then tried to correct itself. I tried to view the sensors output in the serial monitor to better calibrate it, but the data stream is far too fast to read. Am I doing it wrong?

void show_graph(int data) {
  for (int i=0; i<data; i+=50) { // Tune the 50
    Serial.print('=');
  }
  Serial.print('|');
  Serial.print(data);
  Serial.println();
}

void setup() {
    Serial.begin(115200);
}

void loop() {
    int ain = analogRead(A0);
    show_graph(ain);
    // no delay
}

WizenedEE:

rocketman247:
I figured it out. In addition to updating that line, I hab the libraries in the wrong place. Thank you so much!! One more question, though. This robot uses an IR emitter / detector pair to sense a black line, but it's "quirky" and veers way off and then tried to correct itself. I tried to view the sensors output in the serial monitor to better calibrate it, but the data stream is far too fast to read. Am I doing it wrong?

void show_graph(int data) {

for (int i=0; i<data; i+=50) { // Tune the 50
    Serial.print('=');
  }
  Serial.print('|');
  Serial.print(data);
  Serial.println();
}

void setup() {
    Serial.begin(115200);
}

void loop() {
    int ain = analogRead(A0);
    show_graph(ain);
    // no delay
}

Thanks so much, but I'm gonna show my utter ignorance here.... Where does this go? In place of my current Serial.print codes? Or is it an add on?

Well you could try using the show_graph function instead of Serial.print

Depending on several factors, you might also want to write a quick program on your PC to read the serial port and make the graph for you. That would make the serial communication be about ten times faster than that show_graph function.

If you are using Arduino 1.0 and newer, you should do this at the top of the .cpp file, so it is compatible with more versions of the IDE:

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

@TCWORLD: What is the difference between #import and #include? Isn't #include more often used? I never seen #import before.

dkl65:
@TCWORLD: What is the difference between #import and #include? Isn't #include more often used? I never seen #import before.

import is often used in other programming languages like python and java. It's easy to mix them up.

Aparently, #import was a gcc extension, but it's depreciated now. Use #include.

Where does this go?

How can we tell you if you never posted ALl your code.

Sorry about that, i meant #include. I have been doing quite a bit of Objective-C stuff for an iPhone of late, and they use #import.