Problem with Arduino Reading ASCII string project

This is my very first post to an Arduino Forum so here goes.

I am using Arduino 1.0.1. IDE on a UNO board on a VISTA O.S. I have been trying to do the Arduino Read ASCII string project using a common cathode RGB LED. I made the necessary wiring changes (2nd longer lead to GND, other leads to Pins 3, 5 and 6). I followed the instructions on changing the code if using a common cathode RGB LED.

The code compiled and uploaded and the RGB seemed to work as expected but then stopped while I was out of the room looking for a diffuser.

This is the trouble-shooting I did (probably too much) -- all with negative results: checked Tools>Board and Tools>Port -- OK tested that first LED -- all colors OK used 4 different RGB LEDs used the different GNDs on the board used different wires used Pins 9, 10 and 11 and changed the ASCII code accordingly

Using Pins 9, 10 and 11 and then Pins 3, 5 and 6, I uploaded the SparkFun Inventor's Kit RGB code and the RGB LED worked as expected each time.

I then noticed that in the lower left corner of the screen (on the same bar as "Arduino Uno on Com 6") there were some numbers that changed when I switched from the ASCII code to the SKIF code: The ASCII numbers were 53, then 30, then 50. The only SKIF number that came up after several tries was 1. Are those port numbers ? Tools and the board kept showing Port 6.

Thanks for your help.

Are those port numbers ?

No they are the line number that the cursor is currently on. Click on another line and this will change.

As to your project, unless you burned out the LEDs or the pins it is down to loose wiring. You should solder all connections not use solderless bread board.

Hello again. Thanks for responding so quickly.

I see where those lower left corner numbers are related to the cursor position. Thanks.

I have breadboarded Arduino and SFIK sketches on the SFIK system without any technical problems yet -- only typos.

I went back and tested all four RGB LEDS (Instructables) and each color was OK.

I re-wired the SFIK RGB project on Pins 9, 10 and 11 and Pins 3, 5 and 6 and 220 ohm resistors -- both OK.

I left the SFIK RGB wiring (Pins 3, 5 and 6) and resistors and opened the Arduino Read ASCII code from Examples. I made the recommended changes to the "constrain" lines for a common cathode RGB LED. I compiled the code and the RGB LED seemed to do its thing until I clicked UPLOAD. The RGB LED stayed off as I tried to compile again. I opened the Serial Monitor from the Tools menu but the monitor stayed blank.

I have soldered some LED projects from kits. I would like to be able to solder these circuits with an ATmega 328 chip on a small perf board but I'm not there yet. In any case, I like to breadboard everything first but any links that would help me move towards perf board+328 would be appreciated.

In the meantime, I would like to know what the problem with this project is and how to fix it. Thanks again.

In the meantime, I would like to know what the problem with this project is and how to fix it.

Well you have to give us something more to go on than this. The how to use this forum sticky post ( which you have read - right? ) suggests you post the actual code you are using along with a schematic of how it is wired up and a photograph of the wiring.

Hello again.

Thanks for paying attention to the posts. Yes, I have read the instructions about posting but I assumed everyone was familiar with the SFIK and Arduino Read ASCII string RGB LED projects.

I was not able to post my photo into this reply. I took a photo with my IPAD and clicked “Copy” but it didn’t paste in this box. (I was able to copy the photo to Pages but the photo also did not transfer when I copied my entire post+photo to this box.) Any suggestions ?

The USB cord is plugged into the Notebook and the Arduino board. The longest lead of the RGB LED is the cathode and is the second lead from the flat side. A short black wire is connected from that lead to the negative (blue) power bus which is connected by a longer black wire to the GND power pin (next to the 5V power pin) on the Arduino Uno board. As far as I can tell, the resistors and wires are in the correct rows and no bare leads are touching. The blurred text on the blue line above the white text says “Done Uploading.”

The Arduino ASCII project is for a common anode RGB LED. The code can be found at
http://arduino.cc/en/Tutorial/ReadASCIIString?action=sourceblock&num=1
The link worked when I just checked it. This code and the Examples code both were created 4/13/2012. The only thing I changed in the Examples code was what the comment said to change: I removed the "255 - " before “constrain” for “red”, “green” and “blue” in the void loop() section.

If there are any measurements you think might be helpful, please let me know. I’m not a pro with a multi-meter but I’ll try. I’m also sending a working link to the data sheet for the RGB LED used:

was not able to post my photo into this reply.

The how to use the forum sticky you claim to have read tells you how to attach photos. Use the triangular button labled additional options at the bottom right of the reply box.

So basically you are just telling me you did everything right but it won't work. So how am I going to find out what you did wrong?

What we need to know is what you did, not what you think you did. That means posting the code and sending a photo. Then we can check if there is a disconnect between what you did and what you needed to do.

Load the "blink" sketch (or "Blink without delay"). Check that the on-board LED blinks. Connect one anode of the RGB LED to that pin (I/O 13) via the 220 ohm resistor which I trust you always had in series, and ground the cathode.

Does it blink?

If so, move it to each of the I/O pins you have previously used and re-compile the "blink" program in turn to use that pin. If you can get it to blink on each pin in turn, then your hardware is undamaged. Go back to whatever software and hardware configuration last worked.

This sketch?

/*
  Reading a serial ASCII-encoded string.

 This sketch demonstrates the Serial parseInt() function.
 It looks for an ASCII string of comma-separated values.
 It parses them into ints, and uses those to fade an RGB LED.

 Circuit: Common-anode RGB LED wired like so:
 * Red cathode: digital pin 3
 * Green cathode: digital pin 5
 * blue cathode: digital pin 6
 * anode: +5V

 created 13 Apr 2012
 by Tom Igoe

 This example code is in the public domain.
 */

// pins for the LEDs:
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;

void setup() {
  // initialize serial:
  Serial.begin(9600);
  // make the pins outputs:
  pinMode(redPin, OUTPUT); 
  pinMode(greenPin, OUTPUT); 
  pinMode(bluePin, OUTPUT); 

}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int red = Serial.parseInt(); 
    // do it again:
    int green = Serial.parseInt(); 
    // do it again:
    int blue = Serial.parseInt(); 

    // look for the newline. That's the end of your
    // sentence:
    if (Serial.read() == '\n') {
      // constrain the values to 0 - 255 and invert
      // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
      red = 255 - constrain(red, 0, 255);
      green = 255 - constrain(green, 0, 255);
      blue = 255 - constrain(blue, 0, 255);

      // fade the red, green, and blue legs of the LED: 
      analogWrite(redPin, red);
      analogWrite(greenPin, green);
      analogWrite(bluePin, blue);

      // print the three numbers in one string as hexadecimal:
      Serial.print(red, HEX);
      Serial.print(green, HEX);
      Serial.println(blue, HEX);
    }
  }
}

You have to set Serial Monitor up to send a newline ( '\n' ) at the end of every line sent. By default it sends nothing. The setup is down in the lower right corner of Serial Monitor.

    // look for the newline. That's the end of your
    // sentence:
    if (Serial.read() == '\n') {

Hello and thanks to one and all for your suggestions.

Grumpy Mike: I read the entire webpage “Read this before posting a programming question” and thought that was the “sticky” you were referring to. I evidently overlooked “How To Use This Forum” but have gone back and read it.

Thanks for the tip about posting pictures. I clicked on the “Choose File” button just below “Additional Options”, clicked on a picture of the board setup I used today in IPAD Photos and – voila ! – Photo1.

Paul_ _B:

I tried the “Blink” sketch for each of the three colors of the RGB LED. I used the same UNO board, same
1.0.1 IDE, same RGB LED, same 220 ohm resistors and same wires. The short white wire in the photo goes to the Green led.

The L/13 led blinked when I connect the USB cable (power) to the board.

When I uploaded the “Blink” sketch, L/13, TX and RX leds all blinked at least once but only L/13 continued blinking.

I put the RGB LED back, connected the cathode (long lead2 to GND) and connected one lead (Red) to Pin 13 through a 220 ohm resistor. I compiled the “Blink” sketch and the RGB red led and L/13 led blinked as soon as I connected the USB cable and continued blinking before and during compiling and during the initial stage of uploading. It looked like the RGB red led and L/13 led stopped blinking momentarily during the final stage of uploading (while the TX and RX leds blinked) and then the RGB red led and L/13 continued blinking. I got the same results for the Green and Blue leds (separately)

GoForSmoke:

Thanks for the clue about “newline”.

Yes, that’s the ASCII sketch I’ve been using.

Since this is the first time I did an Arduino project using the Serial Monitor I did a simple serial monitor project (4.1) from Arduino Cookbook. The Serial Monitor worked as expected. TX blinked once as each new line printed out automatically.

I re-wired the UNO board for the “Read ASCII string” sketch using the same RGB LED, 220 ohm resistors and wires. I uploaded the code and opened the Serial Monitor.

I left Autoscroll and the 9600 baud as is. I tried a bunch of stuff that did not result in the display of hex code in the lower box of the Serial Monitor with any of the line options. I did some more homework, re-read the Arduino project and typed in their three numbers, first with quotation marks (as shown in the Arduino project and then without. As soon as I typed in the three numbers without quotation marks, the hex code appeared in the lower box and the RGB LED turned ON and stayed on until I typed in another set of three numbers.

What worked:
Set the line option to “Newline”.
Type three numbers between 0 and 255 (each separated by a comma) in the top box of the Serial Monitor – no quotation marks.
Click the SEND button to the right of the top box.
Take photos and write a follow-up post to the Forum.

And say thanks again to everyone who helped me learn a lot more than I knew a few days. I hope our paths cross again.