Problem with atoi in 0021
i'm trying convert sketch 0018 0021. 0021 has built in string function replacing wstring library. compile error @ n = atoi(readstring); line in code below. anybody know changed cause compile error?
code: [select]
// zoomkat 7-30-10 serial servo test
// type servo position 0 180 in serial monitor
// writemicroseconds, use value 1500
// http://arduino.cc/en/uploads/tutorial/string.zip wstring.h
//#include <wstring.h> //provides easy string handling
string readstring = string(100);
#include <servo.h>
servo myservo; // create servo object control servo
void setup() {
serial.begin(9600);
myservo.attach(9);
}
void loop() {
while (serial.available()) {
delay(10);
if (serial.available() >0) {
char c = serial.read(); //gets 1 byte serial buffer
readstring += c;}
//readstring.append(c); } //makes string readstring
}
if (readstring.length() >0) {
serial.println(readstring);
int n;
n = atoi(readstring); //convert string number
//myservo.writemicroseconds(n);
myservo.write(n);
readstring="";
}
}
try:
--
the quick shield: breakout 28 pins quick-connect terminals
code: [select]
n = atoi(readstring.getbytes());--
the quick shield: breakout 28 pins quick-connect terminals
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Problem with atoi in 0021
arduino
Comments
Post a Comment