This code should be sending data to the iphone app Arduino Manager but will not compile, suggestions?
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <Servo.h>
#include <IOSController.h>
#include <avr/wdt.h>
int Trigger = 600; // value photocell reading must be below to trigger "break"
int CumulativeTotal = -3; //initial value of CumulativeTotal = -3 to account for first "test read" on all sensors
const int LEDpinlowred = 9;//Red LED 1
const int LEDpinmidred = 11; //Red LED 2
const int LEDpintopred = 12;//Red LED 3
const int LEDpinStat = 13;
const int laserPin = 5; //Variable power transmitter
/*
*
* Ethernet Library configuration
*
*/
byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0xC5, 0x79 }; // MAC Address assigned to the board
/*
*
* IP info
*
* Using DHCP these parameters are not needed
*/
IPAddress ip(192,168,1,220);
IPAddress gateway(192,168,1,220);
IPAddress subnet(255,255,255,0);
/*
*
* Initialize the Ethernet server library
*/
EthernetServer server(80); // Messages received on port 80
#define CHIPSELECT 4;
/*
*
* Prototypes of IOSController’s callbacks
*
*
*/
void doWork();
void doSync(char *variable);
void processIncomingMessages(char *variable, char *value);
void processOutgoingMessages();
void deviceConnected();
void deviceDisconnected();
/*
*
* IOSController Library initialization
*
*/
begin.IOSController
void setup()
{
Serial.begin(115200);
pinMode(10, OUTPUT); // change this to 53 on a mega
digitalWrite(10, HIGH); // but turn off the W5100 chip!
Ethernet.begin(mac, ip, subnet, gateway);
server.begin();
pinMode(A0, INPUT); //Low Photocell
pinMode(A1, INPUT); //Middle Photocell
pinMode(A2, INPUT); //High Photocell
pinMode(2, OUTPUT); //Seven Segment Display 'a'
pinMode(3, OUTPUT); //Seven Segment Display 'b'
pinMode(4, OUTPUT); //Seven Segment Display 'c'
pinMode(5, OUTPUT); //Seven Segment Display 'd'
pinMode(6, OUTPUT); //Seven Segment Display 'e'
pinMode(7, OUTPUT); //Seven Segment Display 'f'
pinMode(8, OUTPUT); //Seven Segment Display 'g' ------------------
pinMode(9, OUTPUT); //Seven Segment Display 'h' | /0/1/2/ 3 |
pinMode(LEDpinlowred, OUTPUT); //User interface panel LED 0(Red) diagonostics A2 | }
pinMode(LEDpinmidred, OUTPUT); //User interface panel LED 1(Red) diagonostics A1 | 4 |
pinMode(LEDpintopred, OUTPUT); //User interface panel LED 2(Red) diognostics A0 ------------------
pinMode(LEDpinStat, OUTPUT); //User interface panel LED 3(amber) systems status indicator(blink = uploading serial data)(solid = problem)
pinMode(laserPin, OUTPUT); //Powers laser transmission pole
digitalWrite (LEDpinlowred, 0);
delay(350);
digitalWrite (LEDpinlowred, 1);
delay(350);
digitalWrite (LEDpinmidred, 0);
delay(350);
digitalWrite (LEDpinmidred, 1);
delay(350);
digitalWrite (LEDpintopred, 0);
delay(350);
digitalWrite (LEDpintopred, 1);
delay(750);
digitalWrite (LEDpintopred, 0);
delay(350);
digitalWrite (LEDpintopred, 1);
delay(150);
digitalWrite (LEDpinmidred, 0);
delay(150);
digitalWrite (LEDpinmidred, 1);
delay(150);
digitalWrite (LEDpinlowred, 0);
delay(150);
digitalWrite (LEDpintopred, 1);
delay(500);
digitalWrite (LEDpinlowred,0);
digitalWrite (LEDpinmidred,0);
digitalWrite (LEDpintopred,0);
delay(400);
digitalWrite (LEDpinlowred,1);
digitalWrite (LEDpinmidred,1);
digitalWrite (LEDpintopred,1);
delay(400);
digitalWrite (LEDpinlowred,0);
digitalWrite (LEDpinmidred,0);
digitalWrite (LEDpintopred,0);
delay(400);
digitalWrite (LEDpinlowred,1);
digitalWrite (LEDpinmidred,1);
digitalWrite (LEDpintopred,1);
delay(400);
digitalWrite (LEDpinlowred,0);
digitalWrite (LEDpinmidred,0);
digitalWrite (LEDpintopred,0);
delay(400);
digitalWrite (LEDpinlowred,1);
digitalWrite (LEDpinmidred,1);
digitalWrite (LEDpintopred,1);
}
void loop()
{
//iosController.loop();
iosController.loop(500);
}
void doWork() {
delay (1200); // Most useful for tuning, sensor read time
if (analogRead(2) > Trigger){
(++CumulativeTotal);
} // if condition is true add 1 to 'The cumulative total' which will be displayed to the seven segment display.
else // do nothing
if (analogRead(2) < 600) {
digitalWrite (LEDpintopred, 1);
}
if (analogRead(2) > 600) {
digitalWrite (LEDpintopred, 0);
}
delay(1);
if (analogRead(1) > Trigger) {
(++CumulativeTotal);
} // if condition is true add 1 to 'The cumulative total' which will be displayed to the seven segment display.
else// do nothing
if (analogRead(1) < Trigger) {
digitalWrite (LEDpinmidred, 1);
}
if (analogRead(1) > Trigger) {
digitalWrite (LEDpinmidred, 0);
}
delay(1);
if (analogRead(0) > Trigger) {
(++CumulativeTotal);
}// if condition is true add 1 to 'The cumulative total' which will be displayed to the seven segment display.
else// do nothing
if (analogRead(0) < Trigger) {
digitalWrite (LEDpinlowred, 1);
}
if (analogRead(0) > Trigger) {
digitalWrite (LEDpinlowred, 0);
}
delay(10);
if (analogRead(0) > Trigger) {
delay(10000);
}
if (CumulativeTotal > 20){
digitalWrite (LEDpinStat, 1);
}
{
Serial.println ("Total Product Loaded:-");
Serial.println (CumulativeTotal);
}
if (Serial.available()) {
//read serial as a character
char ser = Serial.read();
switch (ser) {
case '1':
analogWrite(laserPin, 50);
break;
case '2':
analogWrite(laserPin, 100);
break;
case '3':
analogWrite(laserPin, 150);
break;
case '4':
analogWrite(laserPin, 200);
break;
case '5':
analogWrite(laserPin, 250);
break;
case '0':
analogWrite(laserPin, 0);
break;
case 'c':
(CumulativeTotal = 0);
break;
case '+':
(++CumulativeTotal);
break;
case '-':
(--CumulativeTotal);
break;
case 'ul58':
(CumulativeTotal = -58);
break;
}
}
void processOutgoingMessages() {
iosController.writeMessage("Total",CumulativeTotal);
}
/**
*
*
* This function is called when the iOS device connects
*
*/
void deviceConnected () {
digitalWrite(CONNECTIONPIN,HIGH);
}
/**
*
*
* This function is called when the iOS device disconnects
*
*/
void deviceDisconnected () {
digitalWrite(CONNECTIONPIN,LOW);
}
}
There is alot of useless code there so let me trim it up. I think the problem is here somewhere
#include <IOSController.h>
#include <avr/wdt.h>
int Trigger = 600; // value photocell reading must be below to trigger "break"
int CumulativeTotal = -3; //initial value of CumulativeTotal = -3 to account for first "test read" on all sensors
const int LEDpinlowred = 9;//Red LED 1
const int LEDpinmidred = 11; //Red LED 2
const int LEDpintopred = 12;//Red LED 3
const int LEDpinStat = 13;
const int laserPin = 5; //Variable power transmitter
/*
*
* Ethernet Library configuration
*
*/
byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0xC5, 0x79 }; // MAC Address assigned to the board
/*
*
* IP info
*
* Using DHCP these parameters are not needed
*/
IPAddress ip(192,168,1,220);
IPAddress gateway(192,168,1,220);
IPAddress subnet(255,255,255,0);
/*
*
* Initialize the Ethernet server library
*/
EthernetServer server(80); // Messages received on port 80
#define CHIPSELECT 4;
/*
*
* Prototypes of IOSController’s callbacks
*
*
*/
void doWork();
void doSync(char *variable);
void processIncomingMessages(char *variable, char *value);
void processOutgoingMessages();
void deviceConnected();
void deviceDisconnected();
/*
*
* IOSController Library initialization
*
*/
begin.IOSController
void setup()
{
Serial.begin(115200);
pinMode(10, OUTPUT); // change this to 53 on a mega
digitalWrite(10, HIGH); // but turn off the W5100 chip!
Ethernet.begin(mac, ip, subnet, gateway);
server.begin();
or maybe here
void loop()
{
//iosController.loop();
iosController.loop(500);
}
void doWork() {
or maybe here
void processOutgoingMessages() {
iosController.writeMessage("Total",CumulativeTotal);
}
/**
*
*
* This function is called when the iOS device connects
*
*/
void deviceConnected () {
digitalWrite(CONNECTIONPIN,HIGH);
}
/**
*
*
* This function is called when the iOS device disconnects
*
*/
void deviceDisconnected () {
digitalWrite(CONNECTIONPIN,LOW);
}
}
Be easy on on me I am a complete newbie on ethernet and not exactly a pro with arduino and libraries
Thanks in advance