Forum >Bluno + RGB + Iphone
Bluno + RGB + Iphone

Hi guys,
I've been doing some projects with my Bluno for a short time, but now I'm trying to work with the Bluetooth and my Iphone. And now, I have some problems with my code.
I'm trying that my Bluno gets a word like "Red" and it turns on the red led of my RGB. It works perfectly using the app Bluno Term, but if I send a different word that doesn´t appear in my code, the code fails.
This is my code with the last test that I tried:
I have another question, Could I use the color wheel of the Play Bluno app without a Bluno Accessory Shield?
Sorry, but I'm a newbie and I have a lot of stupid questions...
Thank you!
I've been doing some projects with my Bluno for a short time, but now I'm trying to work with the Bluetooth and my Iphone. And now, I have some problems with my code.
I'm trying that my Bluno gets a word like "Red" and it turns on the red led of my RGB. It works perfectly using the app Bluno Term, but if I send a different word that doesn´t appear in my code, the code fails.
This is my code with the last test that I tried:
Code: Select all
int RED = 2;
int GREEN = 5;
int BLUE = 7;
char letter;
String word;
void setup()
{
Serial.begin(115200);
pinMode(red,OUTPUT);
pinMode(green,OUTPUT);
pinMode(blue,OUTPUT);
}
void loop()
{
if(Serial.available() > 0)
{
letter = Serial.read();
word += letter;
}
if (word == "Off")
{
setColor(0, 0, 0);
Serial.println(word);
word="";
}else{
if (word == "Red")
{
setColor(255, 0, 0);
Serial.println(word);
word="";
}else{
if (word == "Green")
{
setColor(0, 255, 0);
Serial.println(word);
word="";
}else{
if (word == "Blue")
{
setColor(0, 0, 255);
Serial.println(word);
word="";
}else{
if (word == "White")
{
setColor(255, 255, 255);
Serial.println(word);
word="";
}else{
if (word == "Purple")
{
setColor(255, 0, 255);
Serial.println(word);
word="";
}else{
if (word == "Yellow")
{
setColor(255, 255, 0);
Serial.println(word);
word="";
}else{
word="";
}
}
}
}
}
}
}
}
void setColor(int redc, int greenc, int bluec)
{
analogWrite(RED, redc);
analogWrite(GREEN, greenc);
analogWrite(BLUE, bluec);
}
I have another question, Could I use the color wheel of the Play Bluno app without a Bluno Accessory Shield?
Sorry, but I'm a newbie and I have a lot of stupid questions...
Thank you!
2015-03-25 09:15:51 Hi,
You are right leff, I had a problem with the if else statements. I discovered the problem and I repaired it.
Thank you so much for everything.
Now I have to find the way to use the Play Bluno App or another similar with a single RGB Led...
fernangutiglesias
You are right leff, I had a problem with the if else statements. I discovered the problem and I repaired it.
Thank you so much for everything.
Now I have to find the way to use the Play Bluno App or another similar with a single RGB Led...

2015-03-24 20:17:55 Hi,
Oh, the if-else syntax you used in ur sketch is not properly, you could google it. It should help.
Leff
Oh, the if-else syntax you used in ur sketch is not properly, you could google it. It should help.

2015-03-21 02:32:15 Hi,
1 Yes, that's my problem. If I send any word different that I put in my code, the arduino doesn't understand it, and the word makes that the string word contains new words every time that I send any word.
Can you help me or give me an idea about how to repair my code??
2 I'm not connecting any Accessory Shield, because I'm ussing a simple RGB LED.
fernangutiglesias
1 Yes, that's my problem. If I send any word different that I put in my code, the arduino doesn't understand it, and the word makes that the string word contains new words every time that I send any word.
Can you help me or give me an idea about how to repair my code??
2 I'm not connecting any Accessory Shield, because I'm ussing a simple RGB LED.

2015-03-17 22:34:29 1 if you send 'blue', your RGB should be blue, right? but if you send any word not in the code, sure, the arduino won't recognize it.
2 as long as you wire all devices correctly, it will be ok. Maybe the accessory board you used is for expansion function, so it's not a must.(i am not sure which Accessory Shield you are using )
Leff
2 as long as you wire all devices correctly, it will be ok. Maybe the accessory board you used is for expansion function, so it's not a must.(i am not sure which Accessory Shield you are using )
