I have 2 inputs, one on analog pin A0, the other digital pin 48(pulseIn). Using these inputs I need to change the state of 4 LED's.
I am wanting to create a lookup table for the arduino to use in determining the state of each LED according to what the values of pins A0, and 48.
The way to proceed is to first decide what values to expect on the two inputs, and how those values will be translated to the states of the LEDs. Only you can tell us what to expect, and that can all be explained using simple English.
Once you have defined those conditions, it should be straightforward to convert them into code.
I am having trouble grasping the implementation of an array. What I need to do is basically compare two input pins and use that info to control the state of a few LED's using the array as my lookup table. I have predefined values to place in the array. As much as I hate to ask, can someone "hold my hand" and walk me through implementing and accessing an array?
My apologies for the cross post, I'm not sure how that happened. Below is an abbreviated version of code. I have abbreviated it only because it is repetitive aside from "vssval" values changing. I am trying to get away from having to modify the entire code to change the "vssval" on every line, if that makes sense.
I have read and reread the reference article on arrays and its just not clicking in my head. I have searched the internet and the forum for insight to no avail. I am NOT asking anyone to write code for me only to help me understand the syntax and implementation of arrays.
Ok so now that we have that squared away, can someone give me a lesson on arrays?
My code functions the way I want, don't have any issues with the actual code itself. I would just like to have to predetermined values in a centralized location and use a pointer to that location instead of miles of code with a different value on each line.
pointer to that located in the memory of a CPU is worked out like * and addressed using & in c++ ,this way you just use the same value of a variable that you pointed to instead of making copies of it everytime you need to work with it or its value stored in.
for more use the google.
Using the code I provided could you show me an example? Im having trouble wrapping my head around the syntax more than anything. I havent done any C coding before this and been 20 years since I did anything in Basic. So some of the terms and usage is foreign to my old brain.
Actually Im not able to understand what syntax you want ,by the last post it seemed you want to know how pointers work and prior to that post it seemed like you wanted to know how array are to be declared?
I looked at the array tutorial you posted, it's the closest Ive come across to being understandable to me. Ill read some more and try implementing the example this evening and let you know if I was successful lol. Many thanks.
int ar_[2] = {element1, element2}; this is a one dimensional array. with int ar_[] = {6,7,8} being an open array where the size of the array will be determined based on the elements in the array.
then there are multidimentional arrays like : char ar_multi[][]; which you will hardly need.
In implementation of this project, will I be able to modify the contents of the array via serial comm? I need to be able to update the array for different conditions/use of the project. For example, if i want to change "analogWrite(epc, tpsval / 4) to say analogWrite(epc, tpsval / 6), without having to open the IDE, make changes, upload....I'd like to use hex edit and a serial terminal to make the changes if that is possible.
For example, if i want to change "analogWrite(epc, tpsval / 4) to say analogWrite(epc, tpsval / 6)
Yes, you can just declare an int val[2] = {4,6}; and based on the serial comm. load the respective element in the analogWrite(epc, tpsval/ val[0]); etc