letter substitution program

Hey guys I am very new to arduino and I don't really understand how it works. I have to make a letter substitution program, for each letter of the alphabet I have to substitute it with another letter. I am really lost I've spent an hour reading through this book that I have but it makes no sense. Any help would be much appreciated.

You need to know about arrays, see here a bit about them.
http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

Then you have an array with your scrambled alphabet in it. Then as an index into the array you have the letter (number ) you want to substitute and the contents of the array is the letter you use.
Put the ASCII values of the letters into the array to make it simpler.

This sort of thing is called a look up table if you want to google for more information.

I have to make a

Sounds like an assignment.

Thanks, i'll take a look at that. Yep its an assignment, just to help us get more familiar with the arduino. We will be building a robot later this year.

Also look up the ascii encoding scheme, if you aren't already familiar with it. You'll need to understand this in order to know which element in your lookup table corresponds to which input character.

I've looked at arrays I kind of understand what they are talking about. I'm not sure exactly how to make it substitute a letter for another letter though. Maybe someone could show me an example using letters.

Is "the letter" from some user input?

Here is what the final line could look like

 scramble = scrambleArray[inputLetter];

If you're limited to A..Z uppercase only, you can shorten your array:

 scramble = scrambleArray[toupper(inputLetter) - 'A'];

If you're only concerned with upper case letters, a very tedious way to do it would be 26 if statements, which would hopefully inspire you to learn about arrays.

26 if statements, which would hopefully inspire you to learn about arrays.

Too right it would :), and one would hope that approach would result in a fail.


Rob