Hi,
I'm new to this forum - and relatively new to Arduino boards and programming. I wasn't sure what category this topic should come under so if its in the wrong one then I apologise.
Basically, I am creating a program which requires a value based on an external sensor to be recorded so that it can be used at a future point. I will include a copy of the program at the end of this message.
What I want to know is this, is there any way of storing a value in the Void Setup () { section?
I did a small amount of this a couple of years ago, however, I haven't done anything between then and now, nor have I done any programming prior to that occasion. As such I am still very much a beginner and have a lot to learn. Prior to this I have trawled the forum, the internet and the example programs, however, I cannot find the information I am looking for. Thus, I come to this forum as a last resort to see if anyone can help me.
The program is linked.
The values I am attempting to define are SensorLight, SensorDark and gateSenDark. The pins A0 and A1 are connected to two potential dividers (one each) formed of a resistor and LDR. The Button (A2) value will be connected to A2 via button (currently being represented by a wire from the 5V pin to pin A2.
Ok, thanks for the responses.
You say I need to add a global pointer. In laymans terms what is this?
You must understand, I have only got into computers, electronics and microcomputers in the last few months, thus, most of these terms don't make sense to me. Nevertheless, I will learn.
The way I understand it, I could also make the values global by creating them outside the setup or loop codes. However, I need the lcd display which, I also understand, needs to be inside such code. Is this correct or am I talking nonsense?
AWOL:
Why do you think would want to define a variable inside setup()?
Do you understand what scope means?
Not in the slightest.
AWOL:
I'm not sure what that for loop is doing (it may be OK, but it looks weird), and I'm pretty sure you didn't want to use == .
The idea behind the loop is that the code keeps searching for a change in the state of the Button pin whilst external factors are changed. Also, I wanted a visual output via the LCD. The loop is currently working, however, the issue is that it isn't recording a value (so you could be right about the '==').
I try to achieve what I wan by using methods and code that have worked for me before. Up until this point that has worked for me. The rest of the code I know works, however, this may not be the best way of recording the value, hence why I have appealed to the forum.