Let's Make Robots!

Arduino Librairy Compiling errors

Hello there,


Here is the situation, I have the Newping Librairy correctly added to my librairy folders and Ive been testing the example codes without success. . I cant attach it by importing it from the import librairy function on the sketch. Any help?

Note: I have more detailed information on second post.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

This is the code


I am an arduino duelimove board with adafruit motorshield. Im running my arduino programm on windows 7.


#include <NewPing.h>
#include <AFMotor.h>

#define TRIGGER_PIN  5  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     6  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

AF_DCMotor motor2(2);
AF_DCMotor motor4(4);

void setup() {
  Serial.begin(9600); // Open serial monitor at 9600 baud to see ping results.
 // turn on motor


void loop() {
  delay(50);                // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  int cm = sonar.ping_cm(); // Send out the ping, get the results in centimeters.
  Serial.print("Ping: ");
  Serial.print(cm);         // Print the result (0 = outside the set distance range, no ping echo)



and here is the error:


nouveautest:9: error: 'NewPing' does not name a type
nouveautest.cpp: In function 'void loop()':
nouveautest:27: error: 'sonar' was not declared in this scope

You are totally right, I did change those pins for the IR. This sketch is the base sketch Im working with from someone else. On the other hand I did find what was wrong with the librairys!!! The librairy didnt show in the import librairy menu because I was using the arduino shortcut on my desktop. When I opened my arduino software directly from the folder (not with a shortcut) I had all my new librairy, it took me a while to find that one out. So for all the new guys using an arduino shortcut, make sure to redo your shortcut everytime you add a librairy to your arduino folder.


Thanks Maxhirez!