Go Down

Topic: compiling error (Read 727 times) previous topic - next topic

ndtman

Mar 17, 2013, 06:44 pm Last Edit: Mar 17, 2013, 07:06 pm by ndtman Reason: 1
I am having a hard time compiling a sketch that I copied from an instructable.

I am using the UNO R3 on a windows 7 machine with the current IDE.

the sketch I am using is:

Code: [Select]
#include <Servo.h>

const int servo1 = 3;       // first servo
const int servo2 = 10;       // second servo
const int joyH = 3;        // L/R Parallax Thumbstick
const int joyV = 4;        // U/D Parallax Thumbstick

int servoVal;           // variable to read the value from the analog pin

Servo myservo1;  // create servo object to control a servo
Servo myservo2;  // create servo object to control a servo



void setup() {

 // Servo  
 myservo1.attach(servo1);  // attaches the servo
 myservo2.attach(servo2);  // attaches the servo

 // Inizialize Serial
 Serial.begin(9600);
}


void loop(){

   // Display Joystick values using the serial monitor
   outputJoystick();

   // Read the horizontal joystick value  (value between 0 and 1023)
   servoVal = analogRead(joyH);          
   servoVal = map(servoVal, 0, 1023, 0, 180);     // scale it to use it with the servo (result  between 0 and 180)

   myservo2.write(servoVal);                         // sets the servo position according to the scaled value    

   // Read the horizontal joystick value  (value between 0 and 1023)
   servoVal = analogRead(joyV);          
   servoVal = map(servoVal, 0, 1023, 70, 180);     // scale it to use it with the servo (result between 70 and 180)

   myservo1.write(servoVal);                           // sets the servo position according to the scaled value

   delay(15);                                       // waits for the servo to get there

}


/**
* Display joystick values
*/
void outputJoystick(){

   Serial.print(analogRead(joyH));
   Serial.print ("---");
   Serial.print(analogRead(joyV));
   Serial.println ("----------------");
}



The errors I am getting are:

C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp: In member function 'uint8_t Servo::attach(int)':
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:28: error: 'digitalWrite' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:29: error: 'OUTPUT' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:29: error: 'pinMode' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp: In member function 'void Servo::write(int)':
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:52: error: 'clockCyclesPerMicrosecond' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp: In static member function 'static void Servo::refresh()':
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:74: error: 'millis' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:107: error: 'digitalWrite' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:109: error: 'TCNT0' was not declared in this scope
C:\Users\====\Documents\Arduino\libraries\Servo\Servo.cpp:124: error: 'digitalWrite' was not declared in this scope

It has to be something simple and I have found a couple post about # include <wire.h> needing moved from servo.h to servo.cpp. I did that but still the same errors.

The only libraries that show up in my library list are Motor shield, servo and software servo. Shouldn't I have a larger list???

This is a simple project I am working on with my son for an animatronics puppet for school. I have had the example sweep working in the past but now I seem to get the same errors when I load that one too.

Can someone please help as I am certain it is either something I have done or something I am missing.

Thank you and I will do a formal introduction post here in the near future.

Regards,
NDT

Grumpy_Mike

Read the sticky post about how to use this forum. Then go back and modify that post to include the code tags.

It looks like you haven't installed the IDE correctly.

ndtman

Please explain the install as I do believe I followed the instructions correctly. However I am a hardware guy and not as knowledgeable about the software end.

robtillaart


I tried your sketch with the IDE1.03 and it compiled right away.

Which version of the IDE do you use? 
There were some breaking interfaces since version 0.23
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Grumpy_Mike

Thanks for changing the post. It is so much easier to copy and paste and try your code.
I to got this to compile straight off using IDE 1.0.3.
It looks like all the files are not in your system. Try and remove it and install it again.
Sorry I can't be more specific as I am on a Mac.

ndtman

Understood about the first post. I was in a hurry because the wife was pushing me to hurry up so we could leave. I am using 1.0.3 and don't see an uninstaller. I went to my program files and deleted as well as my documents where the other files are stored and deleted them as well.

I will reinstall the most current which is 1.0.3.

It is very strange as a different sketch I had worked fine is now not working as well. Hopefully the fresh install will fix the problem. Thanks for the help hopefully between all here I can get running in no time.

Regards,
NDT

ndtman

Thanks guys I knew it was something stupid. However not being versed in programming I was not thinking. I installed 1.0.4 and flamo my problem went away. It seems that my installation was corrupt. I have no idea as to why but it was.

The next problem after getting my IDE fixed was my kids knocked my breadboard down and didn't tell me they had pulled a wire loose. They put it back or thought they had and it caused an IO pin to get grounded. Lucky enough when I did not have the power up LED upon my software reinstall. I knew something was not right. So I started over and reconnected all my jumper wires.

Good thing was I did not brick my arduino because of the grounding.

Anyhow thank you again for the direction.

Best regards,

Go Up