Brand new to coding, looking for help on a senior project

Hey all,

So, I've taken a couple of courses on C but they weren't as involved as this project that I'm working on requires and I am in need of some guidance. I've taken a few pieces of code from the Arduino public libraries and kind of....attempted to splice them together, so bare with me here.

What I'm trying to do is create a calculator that takes 4 variables provided by user input via an IR remote (Didn't have the keypad in my kit) and performs a formulaic calculation and prints out the result. Since I pulled code from a program designed to use a keypad there is a couple things I'm trying to translate to the way the IR code/library is set up.

Specifically, I'm wondering how to differentiate between the variables as they are entered. I see the code I have here will take the IR remote input and store it, and later use it to perform the calculation...but how do I move from one value to inputting another? For instance, I enter 1 for Num1, how do I enter Num2 without overwriting Num1?

I also left in part of the keypad code because I'm not sure what the function if it is, if anyone could tell me what the function of the below is it would help as well.

key=kpd.getKey();

Again I apologize for the mess of code, very much a newbie at this stuff.

In those C courses that you took, did they teach the concept of "breaking a problem into manageable parts"?

You have posted code on an offsite resource. Many people avoid following such links for security reasons, and also because it's easier to read online when posted with code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons.

aarg:
In those C courses that you took, did they teach the concept of "breaking a problem into manageable parts"?

You have posted code on an offsite resource. Many people avoid following such links for security reasons, and also because it's easier to read online when posted with code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons.

They did, but they were 2+ years ago and it was a couple of basics classes so we only covered simple functions. Not saying that I didn't learn a way to solve this problem in those classes but again that was a while ago and I don't remember it all because I haven't had to do much coding since.

As for posting the code here, how do I go about doing that?

As for posting the code here, how do I go about doing that?

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

In principle, if you are entering several data items during a session, you must define either a separator character (say the OK key on an IR keypad) or set a timeout. When the separator character is read by your sketch, or the timeout is reached, all the previous character are moved into a buffer where they are held for later processing.

like this?

-jim lee

Write a function to store a number into a variable until an "end" key such as '#' is received. When the number is complete convert the input from a string of characters to an actual number and store it in a level of an array and increment the array index. Keep doing this until you have 4 entries in the array. The entries in the array can then be used to perform the calculations you require.

Break the problem into small parts :

Write a function to read the single character inputs and save them as a text representation of a number
Test the function

Convert the text to a real number and save it to the array
Test the conversion by reading the number from the array and multiplying it by say 10

Read 4 numbers and store them as numbers in the array
Test this by reading the 4 numbers from the array and multiplying them together and printing the result

Consider putting the code for each of the above steps in their own function to help with testing
Ensure throughout that appropriate data types are used that can hold the required number ranges