Go Down

Topic: Compile error : 'OUTPUT' was not declared in this scope (Read 4502 times) previous topic - next topic

rocketman247

Quote

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

https://sites.google.com/site/arduinorobotics/home/chapter4_files

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!!

Tom Carpenter

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

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

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?

WizenedEE


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?

Code: [Select]

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
}

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?

Code: [Select]

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?

WizenedEE

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.

dkl65

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:
Code: [Select]

#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.
Visit http://www.glenof.webs.com/!

WizenedEE

@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.

Grumpy_Mike

Quote
Where does this go?

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

Tom Carpenter

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.
~Tom~

Go Up