Serial Monitor Multiple Inputs

As you can probably guess I am a noob and am trying to learn arduino with close to no programming experience. I am trying to use the virtual serial monitor to recieve multiple inputs from one message. I HAVE googled this but being the noob I am I can't seem to gain anything from what I have read.

My project is basically just trying to get my arduino to ask for three values(Red, Green, Blue) and then use those values to create colors on my RGB led. My led is wired correctly as I have tested it with other programs from the net just to see if it worked.

The code I semi-made semi-stole is below. Please help!


int redPin = 11;
int greenPin = 10;
int bluePin = 9;
int Red = 0;
int Green = 0;
int Blue = 0;
void setup()
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
void loop()
  if (Serial.available())
     Serial.print("Red Value?");
     Serial.println(" ");
     int Red =;
     Serial.print("Green Value?");
     Serial.println(" ");
     int Green =;
     Serial.print("Blue Value?");
     Serial.println(" ");
     int Blue =;
     setColor(Red, Green, Blue);
   setColor(Red, Green, Blue);
void setColor(int red, int green, int blue)
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);

Yes, I did post this twice but I thought the people viewing Programming Questions could help me out more than project guidance

Many thanks and have a good day.

Not too dissimilar, below is code that receives messages via the serial port and parses the received data to send specific servos to specific positions.

//zoomkat 11-22-12 simple delimited ',' string parse 
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added 
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo 

void setup() {

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control 
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or combined like 30c,180b,70a,120d,

  if (Serial.available())  {
    char c =;  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
          Serial.print("writing Microseconds: ");
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
          Serial.print("writing Angle: ");
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
         readString=""; //clears variable for new input
    else {     
      readString += c; //makes the string readString

Thanks for the reply but as I said, I am a noob. thus I have no clue what I am looking at :sweat_smile: ... If someone could completely breakdown going from an input of x,y,z to 3 separate variables that would be very appreciated :slight_smile: Sorry for being such a noob...

This demo which has a few different techniques for getting data from the Serial Monitor may help.

Sometimes you need to study code 3 or 4 or 12 times before it starts to make sense.