Pages: [1]   Go Down
Author Topic: Compile error : 'OUTPUT' was not declared in this scope  (Read 4117 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

To:
Code:
#import <Arduino.h>


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

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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?
Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
Logged


Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where does this go?
How can we tell you if you never posted ALl your code.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

~Tom~

Pages: [1]   Go Up
Jump to: