Characters into an array

Hey guys, I have a problem that I can’t figure out. I want the arduino to read an IR input and label it as whatever I have in the first column of the array (‘1’, ‘5’, ‘Ch+’, etc.) I was able to get ‘0’ through ‘9’ but when my serial.print() function does ‘Ch+’ or ‘Enter’ it only does the last character value in that label so ‘+’ and ‘r’. Is there a way to convert just the numbers back into their numbers (‘1’ = 1) but leave the ‘Ch+’ and ‘Enter’ as is so that if I push Ch+ or Enter on the Sony remote that I have, it prints on the screen as what it says. Much help will be appreciated. Thank you

unsigned long Remote[12][2] = {{'0', 1001000},
                     {'1',1},
                     {'2',1000000},
                     {'3',100000},
                     {'4',1100000},
                     {'5',10000},
                     {'6',1010000},
                     {'7',110000},
                     {'8',1110000},
                     {'9',1000},
                     {'Ch+',100},
                     {'Enter',1101000}};

What would also be the easiest way to break a for loop if it were to read an input from an IR Sony remote? (Example, I have a stepper/servo moving for a certain amount of angle/distance but if I wanted to stop it at a certain point, I can just push the Power button) I’ve been working on that all day but it makes my motor all glitchy.

                     {[glow]'Ch+'[/glow],100},
                     {[glow]'Enter'[/glow],1101000}};

The highlighted parts are junk. A character (stuff between single quotes ') is just a character, not a string. Without trying I would say the compiler rejects it, and even if it doesn't, your code wouldn't do what you want. Also, that you put characters into variables of type long is also very bad practice, specially if you don't do it out because of a conscious design decision. You should look up in your favourite C or C++ book what struct does. That's what you need here.

Korman

Without trying I would say the compiler rejects it

Try it - there's nothing wrong with a multi-character constant, though as you correctly point out, it isn't a string, and probably won't do what the OP wants.

Thanks guys for your input. I am more than likely going to go out and buy a C programming book. Not sure what good books are out there (ones that have an easy to understand format with lots of examples). Maybe C programming/language for dummies?

What my objective was, was to get my IR receiver to translate the code and define it with its associated value that it shows on the Sony Remote. I looked at the arduino reference site of the string arrays but I am still a bit confused. Can string arrays still store numerical values as numbers (not characters)?

I ended up taking out the single quotations and did everything in simple numbers that I will define later. This seems to work just fine when the Serial.print() shows what I press.

unsigned long Remote[12][2] = {{0, 1001000},
                     {1,1},
                     {2,1000000},
                     {3,100000},
                     {4,1100000},
                     {5,10000},
                     {6,1010000},
                     {7,110000},
                     {8,1110000},
                     {9,1000},
                     {20,100},
                     {30,1101000}};

Thanks guys for your input. I am more than likely going to go out and buy a C programming book. Not sure what good books are out there (ones that have an easy to understand format with lots of examples). Maybe C programming/language for dummies?

Are you looking for a book or other form of reference on "ANSI C."

Don't get caught up in the newer C-direvtitives like C# or Obj-C. They won't teach you what you need to know to program the Arduino. (And by learning ANSI C, you will be on your way to learning the other forms.)

Yeah, ANSI C. I took a class on it two years ago at the university I am attending. Then I sold the book back to the school which was bad, but then I remembered the book being difficult to understand as well so, meh. I didn't think I would use C programming but I am using it a lot more now and actually enjoy some extent of it but again, I feel like I know less than half of the C language and wouldn't hurt to brush up and use as a reference guide.

Got any recommendations for books?

Kelley and Pohl's 'A Book On C'. Much easier read than K&R

I'll take a look at that book the next time I stop by Barnes and Noble. Thanks. If you got an extra used one you'd like to sell for cheaper than online prices, let me know. ;)