24;error

why do I keep getting this error when trying to use the servo example sketch

#include <Servo.h>

// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott http://people.interaction-ivrea.it/m.rinott

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

why do I keep getting this error when trying to use the servo example sketch

This error?

Wrong board type selected? Compiles okay for me with Uno.

staggley:
why do I keep getting this error … “24”

That’s not an error. THIS is an error:

test.cpp: In instantiation of `std::unary_negate<ci_less>':
test.cpp:77: instantiated from here
test.cpp:77: no type named `argument_type' in `struct ci_less'
/usr/include/c++/3.2.2/bits/stl_function.h:278: no type named `argument_type'
in `struct ci_less'
/usr/include/c++/3.2.2/bits/stl_algo.h: In function `void
std::partial_sort(_RandomAccessIter, _RandomAccessIter, _RandomAccessIter,
_Compare) [with _RandomAccessIter =
__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocator<std::string> > >, _Compare = std::unary_negate<ci_less>]':
/usr/include/c++/3.2.2/bits/stl_algo.h:2138: instantiated from `void std::__introsort_loop(_RandomAccessIter, _RandomAccessIter, _Size, _Compare) [with _RandomAccessIter = __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, _Size = int, _Compare = std::unary_negate<ci_less>]'
/usr/include/c++/3.2.2/bits/stl_algo.h:2209: instantiated from `void std::sort(_RandomAccessIter, _RandomAccessIter, _Compare) [with _RandomAccessIter = __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, _Compare = std::unary_negate<ci_less>]'
test.cpp:77: instantiated from here
/usr/include/c++/3.2.2/bits/stl_algo.h:2557: no match for call to `(
std::unary_negate<ci_less>) (std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)'
/usr/include/c++/3.2.2/bits/stl_algo.h: In function `const _Tp&
std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp =
std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
_Compare = std::unary_negate<ci_less>]':
/usr/include/c++/3.2.2/bits/stl_algo.h:2147: instantiated from `void std::__introsort_loop(_RandomAccessIter, _RandomAccessIter, _Size, _Compare) [with _RandomAccessIter = __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, _Size = int, _Compare = std::unary_negate<ci_less>]'
/usr/include/c++/3.2.2/bits/stl_algo.h:2209: instantiated from `void std::sort(_RandomAccessIter, _RandomAccessIter, _Compare) [with _RandomAccessIter = __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, _Compare = std::unary_negate<ci_less>]'
test.cpp:77: instantiated from here
/usr/include/c++/3.2.2/bits/stl_algo.h:124: no match for call to `(
std::unary_negate<ci_less>) (const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, const

Next time please copy and paste your error. And specify what board you are using and what version of the IDE.

How to use this forum

Sorry it is a uno and 1.0.5

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

Just one include of Servo,h usually works for me.

C:\Users\staggley\Documents\Arduino\libraries\Servo\Servo.cpp: In member function 'uint8_t Servo::attach(int)':

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

Where does “24;error” come into it?

Where does "24;error" come into it?

I had been getting this error in a earlier release of the ide and upgraded to 1.0.5

staggley:
why do I keep getting this error when trying to use the servo example sketch

I just tried your code and did not get any error.

Yes then why do I get errors is it windows7?.

Yes then why do I get errors is it windows7?.

No. It's likely because the copy of the Servo library that you downloaded from who knows where has not been upgraded to work with 1.0. Delete it, since the Servo library is now a standard library.

This is the library that is included in the arduino IDE from the arduino site

This is the library that is included in the arduino IDE from the arduino site

No, it probably isn’t.

C:\Users\staggley\Documents\Arduino\libraries\Servo\Servo.cpp

The path C:\Users\staggley\Documents\Arduino looks like your sketch directory. The libraries folder in that path is for user-downloaded libraries. That is not the core library folder.

Ok thanks it is probably some silly mistake on my part I am not computer savey to old for learning new tricks. I will just have to keep trying.

Thanks guys, I deleted anything arduino and reinstalled all works now. :D