I've borrowed some code from this RGB Mixer http://lab.guilhermemartins.net/2010/07/22/processing-to-arduino/ and modified the arduino side to put the RGB (in my case just R and B) values into variables before sending them to the analog pins because I will also need the values for something else later on, it still works fine with the processing app (for the red and blue slider). I outputted the serial commands to the processing terminal to see what it was sending and it's as simple as RXXXBXXXGXXX, the X's being the value of the slider (0-255)
so I would think that if I don't use the processing app and just open an arduino terminal I should be able to type in my values manually like R255B255, it would set the LED to those values but it has no effect on the LED. It still works fine when I run the processing app, even though I've removed the G from my arduino code, which is what I want.
the reason I'm doing this is because the other half of the project is being written in VB and we will send values to the serial port in the same manner that processing does but I'm just testing it manually right now and it's not working at all.
here is my arduino code for you to see. My question is why isn't it taking the values that I manually put into the arduino serial monitor?
int SerialVal1;
int SerialVal2;
void setup()
{
// declare the serial comm at 9600 baud rate
Serial.begin(9600);
// output pins
pinMode(9, OUTPUT); // red
pinMode(10, OUTPUT); // blue
}
void loop()
{
// call the returned value from GetFromSerial() function
switch(GetFromSerial())
{
case 'R':
SerialVal1 = (GetFromSerial());
break;
case 'B':
SerialVal2 = (GetFromSerial());
break;
}
analogWrite(9, SerialVal1);
analogWrite(10, SerialVal2);
}
// read the serial port
int GetFromSerial()
{
while (Serial.available()<=0) {
}
return Serial.read();
}