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