(Solved)Problems with playground servo tutorial

Hello all. I'm trying to learn how to control servos but I'm having a problem with the tutorial I'm trying to follow in the playground (Arduino Playground - SingleServoExample).

When I try to compile the example sketch in the tutorial I get a bunch of errors concerning the servo.cpp file:

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

I have done everything exactly as the tutorial said to do, but now I'm stuck. I searched the forums for a solution, but the only thing I found was someone with the same problem but didn't give enough information for anyone to help with a solution (Neither Knob nor Sweep servo sketches compile - Programming Questions - Arduino Forum). As was suggested in that thread, I made sure my sketch and servo library are in the correct folders, but it's still not compiling.

Anyone know what is happening?

I think it’s a problem with the “includes”.

Try to add “#include <Arduino.h>” in the sketch and, if it’s not there, in both .h and .cpp of the libraries you are using (in this case, Servo.h and Servo.cpp).

Hope this helps

Thanks agju, it compiles fine now and it uploaded to my uno. But now I can’t figure out how to control it, the servo just sits there doing nothing :frowning:

I’ve tried sending 0-9, w,a,s, and d through the serial monitor, but I’m not even sure if thats how this sketch was meant to be controlled.

RaveCraft:
I've tried sending 0-9, w,a,s, and d through the serial monitor, but I'm not even sure if thats how this sketch was meant to be controlled.

To control the servo with a mouse, here's a simple code made with processing to do the job. You don't have to use this code, you can also send commands to the arduino board from arduino IDEs Serial monitor. (Servo position 0 to 180 are commands 0s and 180s respectively)

Make sure you have selected the correct serial port and the correct speed, then type 0s(return) and 180s(return into the serial monitor, If it doesn't do anything then check that your servos have an adequate power supply which has the ground connected to the Arduino ground and that the control inputs are connected to the appropriate Arduino pins i.e. 14 and 15.