Hi
This is my first post and I'm a noob to programming so take it easy XD .
Running into issues as I don't fully understand programming (probably a to big project for me) but if someone puts me on the right track I am sure Ill be able to make it work.
Commands that I receive from my Iphone (using Mote app can send custom commands over TCP/ip) via the wifi shield (dfrobot shield so the input from the shield is serial) are a string of ascii characters if I use int/String I get 11410110011111013 and if I use byte or char I get "redon"
I was wondering on how to compare this to a set value.
I can switch one led on and off but when I try to control multiple leds it seems that arduino sees two different commands as the same (eg redon switches both leds on and greenon switches both leds on same thing for redoff and greenoff ).
Here is my code:
#define LEDGREEN 12
#define LEDRED 11
byte inByte='0';
byte ReOn = 'redon';
byte ReOff = 'redoff';
byte GrOn = 'greenon';
byte GrOff = 'greenoff';
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
pinMode(LEDRED,OUTPUT);
pinMode(LEDGREEN,OUTPUT);
}
void loop() {
if (Serial1.available()>0) {
inByte = Serial1.read();
Serial.print(inByte);
}
if (inByte==ReOn){
digitalWrite(LEDRED, HIGH);
}
if (inByte==ReOff){
digitalWrite(LEDRED,LOW);
}
if (inByte==GrOn){
digitalWrite(LEDGREEN, HIGH);
}
if (inByte==GrOff){
digitalWrite(LEDGREEN,LOW);
}
}
Here is another piece of code. With this code I get a an error:
IPHONE_WIFI_ARDUINO__experiment.cpp: In function 'void loop()':
IPHONE_WIFI_ARDUINO__experiment:30: error: duplicate case value
IPHONE_WIFI_ARDUINO__experiment:22: error: previously used here
IPHONE_WIFI_ARDUINO__experiment:34: error: duplicate case value
IPHONE_WIFI_ARDUINO__experiment:26: error: previously used here
:
#define LEDGREEN 12
#define LEDRED 11
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
pinMode(LEDRED,OUTPUT);
pinMode(LEDGREEN,OUTPUT);
}
void loop() {
if (Serial1.available()) {
char inByte = Serial1.read();
Serial.print(inByte);
switch(inByte){
case 'redon':
digitalWrite(LEDRED,HIGH);
break;
case 'redoff':
digitalWrite(LEDRED,LOW);
break;
case 'greenon':
digitalWrite(LEDGREEN,HIGH);
break;
case 'greenoff':
digitalWrite(LEDGREEN,LOW);
break;
}
}
}
Any help would be much appreciated. I'm also willing to learn anything I can so any comments will always be helpful :).
Jon Czudek
P.S. Let me know if need to know anything else

