Go Down

Topic: Changing int numbers with external means (Read 1 time) previous topic - next topic

jokefox

Apr 15, 2018, 09:01 pm Last Edit: Apr 15, 2018, 09:24 pm by jokefox
So like

#define lightsonhour 12
#define lightsonmin 0
#define lightsoffhour 0
#define lightsoffmin 0

Or

Const int lightsonhour 12
Etc


Which one would i use and how do you change one of those numbers with say 2 bottons? One button up and one button for down for each hour and minute minute?

I have a nextion display where i can have all the buttons in the world.

My code is wayyy to large to post. It exceeds the post limit but i can do a snippet if needed.

I hope this makes sense as im not to sure how to ask the question. Im close as heck to finishing this project and i just need this settings part done.

BulldogLowell

#1
Apr 15, 2018, 09:08 pm Last Edit: Apr 15, 2018, 09:09 pm by BulldogLowell
you cannot change either a const or a compile-time constant (i.e. #define) programmatically (run-time).

of course, you can change non-const variables...

jokefox

Ok so if it was

Int lightOnhour 12
Blah blah


So instead of const in. Or define. Id use int.

But how do you change that with input from a person?

Like im gonna assume im gonna use a counter for this

So like button press (counter++)
{Int ++}

But what im having and issue with is what do i put in the first {}  like how do i specify that i want to change that int.
And how do i save it so it stays at that number with each loop
Or does it just stay there automatically?

slipstick

If you give some details of what you're actually trying to do we could probably help. But trying to explain the entire language to you one statement at a time with no idea of why you want to know is way too much like hard work. There are plenty of Arduino and C++ tutorials, try the top of the page under Resources or the many example programs in the IDE.

OTOH if you have a real program in mind tell us what it's supposed to do, post your best attempt at it and say what problems you're having. Then we'll have something to start from.

Steve

BulldogLowell

Ok so if it was

Int lightOnhour 12
Blah blah


So instead of const in. Or define. Id use int.

But how do you change that with input from a person?

Like im gonna assume im gonna use a counter for this

So like button press (counter++)
{Int ++}

But what im having and issue with is what do i put in the first {}  like how do i specify that i want to change that int.
And how do i save it so it stays at that number with each loop
Or does it just stay there automatically?

make a little program that attempts to do what you want it to ... then try it.

jokefox

I have a 8 relay board.
Each relay is connected to a light or a fan.

I have the code all written and what not for a headless
System. You would just need to modify the code in the ide
To change any light times. Or pump times or whatever.

Im trying to add a display to this now.

I need to know how to change these times with button presses so i dont need to change it from the idea.
The code is written and everything and its way to long to post. It exceeds the max posting limit.

So
What im having problems with is how do i start to set up the code for the adjustment of int with push buttons?

Im bad at explaining myself and i think i lack the right terms for this situation

AWOL

Quote
The code is written and everything and its way to long to post
So, to summarise, you've written too much code before you understand what the code should look like.

jokefox

What?

You dont need an attitude man.

Im asking a simple question
Im hear to learn.

I havent tried to change and int before so i dont know how to start the push button counter to know what i want it to do.

I dont even believe you would have such attitude. Sorry not everyone knows how to code super easy

AWOL

Coding isn't, and never has been, "super easy" for me.

Suddenly arriving at more that 9.5k of code and finding problems with the code has never been a problem I've encountered either.

(I leave you with that hint - you clearly don't want my help)

jokefox

Wtf are you even saying.

Im not having any issues with my code.

Im trying to make it from a headless program that
Can only be modified from within the ide

To a program with a tft display.

What i need is to be able to change some numbers
With buttons so i can test it to move onto patching
The tft controls threw.

The only part in this i havent learn is
How to change int numbers with a button.

Ive been doing this for only a week so calm
Yourself. Ive gotten some amazing help from people
So either be one of those people or move on from
This and go moderate some other stuff or whatever
A mod is supposed to be doing. Instead of being a troll

AWOL

Quote
Im not having any issues with my code.
Me neither - I can't see it.

Quote
The only part in this i havent learn is
How to change int numbers with a button
I have no idea what that means.

jokefox

Me neither - I can't see it.
I have no idea what that means.
So ill try to post the file?

And i dont know what it means either. I dont know what term im trying to use.

You know when you get one of those wall timers?
And you can put an on and off time.
Im trying to do that part where you use the buttons to change the time it turns on and off

AWOL

So ill try to post the file?

And i dont know what it means either. I dont know what term im trying to use.

You know when you get one of those wall timers?
And you can put an on and off time.
Im trying to do that part where you use the buttons to change the time it turns on and off
All I can see is a lot of hand-waving (without using a shift key)

jokefox

k so ill show you here what i mean buy what i want to change,
i know i need to change it from "#define" to "int"

ive attached the whole code, what i want is to change all the times below with buttons instead of going into
the ide, changing them and then re compiling the code, does that make sense?

Code: [Select]
                                                                       //LIGHT ON AND OFF TIMES

//Light 1
//on
#define light1OnHour 2
#define light1OnMinute 1
//off
#define light1OffHour 14
#define light1OffMinute 1

//Light 2
//on
#define light2OnHour 2
#define light2OnMinute 6
//off
#define light2OffHour 14
#define light2OffMinute 6

                                                                          // PUMP ON TIMES (24 HOUR FORMAT)
//   pump  on times 1
#define pump1ONhour 2             //hour
#define pump1ONmin 0             //minute
#define pump1ONsec 0            //second

//   pump  on times 2
#define pump2ONhour 6             //hour
#define pump2ONmin 0             //minute
#define pump2ONsec 0            //second

//   pump 1 on times 3
#define pump3ONhour 8            //hour
#define pump3ONmin 0            //minute
#define pump3ONsec 0           //second

//   pump 1 on times 4
#define pump4ONhour 10            //hour
#define pump4ONmin 0             //minute
#define pump4ONsec 0            //second

//amount of time water is on for; watering length ; delay untell off
#define watertime 17000

//amount of time circulation pump turns on BEFORE water pump does (use negative)
#define circulationbefore -1

//amount of time circulation pump stays on for AFTER water pump does (use positive)
#define circulationafter +15

AWOL

The IDE's editor ( or indeed any half decent editor) has a search-and-replace feature.

Go Up