This is the line giving me trouble:
steerServoPos = map(atoi(value), 0, 1023, 90, 180);
Which is part of:
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <IOSController.h>
/* Start your code (defines) */
#include<Servo.h>
//Declare Servos
Servo steerservo; //steering servo
Servo throttleservo; //drive servo
const int steerservopin=22; //pin number for steering servo
const int throttleservopin=24; //pin number for throttle servo
int throttleServoPos;
int steerServoPos;
#define CHIPSELECT 4
/* End your code */
/*
*
* Initialize the Ethernet server library
*/
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192,168,1,145);
IPAddress gateway(192,168,1,2);
IPAddress subnet(255,255,255,0);
EthernetServer server(80);
#define CHIPSELECT 4
/*
*
* Prototypes of IOSController's callbacks
*
*
*/
void doWork();
void doSync(char *variable);
void processIncomingMessages(char *variable, char *value);
void processOutgoingMessages();
void processAlarms(char *variable);
void deviceConnected();
void deviceDisconnected();
/*
*
* IOSController Library initialization
*
*/
IOSController iosController(&server,&doWork,&doSync,&processIncomingMessages,&processOutgoingMessages,&deviceConnected,&deviceDisconnected);
/******* Start Global Variable for Widgets *******/
/******* End Global Variable for Widgets *******/
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip, subnet, gateway);
server.begin();
/* Start your code (setup) */
steerservo.attach(steerservopin); // attaches the steering servo to its pin 12
throttleservo.attach(throttleservopin); // attaches the throttle servo to its pin 13
// Servo position at 90 degrees
steerServoPos = 90;
throttleServoPos=90;
steerservo.write(steerServoPos);
throttleservo.write(throttleServoPos);
//delay(1000); // delay one second
/* End your code */
}
void loop() {
iosController.loop(50);// was 500
}
/**
*
*
* This function is called periodically and its equivalent to the standard loop() function
*
*/
void doWork() {
/* Start your code (doWork) */
steerservo.write(steerServoPos);
throttleservo.write(throttleServoPos);
/* End your code */
}
/**
*
*
* This function is called when the ios device connects and needs to initialize the position of switches and knobs
*
*/
void doSync (char *variable) {
/* Start your code (doSync) */
if (strcmp(variable,"JoystickX")==0) {
iosController.writeMessage(variable,map(steerservo.read(),0,180,0,1023));
}
if (strcmp(variable,"JoystickY")==0) {
iosController.writeMessage(variable,map(throttleservo.read(),0,180,0,1023));
}
/* End your code */
}
/**
*
*
* This function is called when a new message is received from the iOS device
*
*/
void processIncomingMessages(char *variable, char *value) {
if (strcmp(variable,"JoystickX") == 0) {
if (atoi(value)>0) {
joystickJoystickMoveRightCallback(atoi(value));
}
else {
joystickJoystickMoveLeftCallback(-atoi(value));
}
}
if (strcmp(variable,"JoystickY") == 0) {
if (atoi(value)>0) {
joystickJoystickMoveBackwardCallback(atoi(value));
}
else {
joystickJoystickMoveForwardCallback(-atoi(value));
}
}
/* Start your code (processIncomingMessages) */
/* End your code */
}
/**
*
*
* This function is called periodically and messages can be sent to the iOS device
*
*/
void processOutgoingMessages() {
/* Start your code (processOutgoingMessages) */
/* End your code */
}
void deviceConnected () {
/* Start your code (deviceConnected) */
iosController.writeTxtMessage("Msg","Hello, I'm your Arduino board");
Serial.println("Ipad Rover Device connected");
/* End your code */
}
void deviceDisconnected () {
/* Start your code (deviceDisconnected) */
Serial.println("Device DISconnected");
/* End your code */
}
/* Widgets synchronization callbacks */
/* Widgets operations callbacks */
void joystickJoystickMoveRightCallback(int value) {
/* Start your code (joystickJoystickMoveRightCallback) */
steerServoPos = map(atoi(value), 0, 1023, 90, 180);
/* End your code */
}
void joystickJoystickMoveLeftCallback(int value) {
/* Start your code (joystickJoystickMoveLeftCallback) */
// Serial.print("\n JoystickX ");
// Serial.println( value );
/* End your code */
}
void joystickJoystickMoveForwardCallback(int value) {
/* Start your code (joystickJoystickMoveForwardCallback) */
// Serial.print("\n JoystickY ");
// Serial.println( value );
/* End your code */
}
void joystickJoystickMoveBackwardCallback(int value) {
/* Start your code (joystickJoystickMoveBackwardCallback) */
// Serial.print("\n JoystickY ");
//Serial.println( value );
/* End your code */
}
/**** User Functions *****/
/* Start your code (User Functions) */
/* End your code */