I need help setting variable called "hour" and "minute". that way I can refer back to the what value "hour" is for an if argument. the idea is when the clock reads a certain time it will start the if statements based on the current time. keep in mind this is my first program, and not be rude but I only want advice on the current issue, I don't want people telling me how I should rewrite my code. I am using the Arduino uno with AtMega 328p-pu IC.
I was going to add a small digital clock display and have two buttons to change the hour and minute. the IC I am using has a crystal oscillator so that and the user being able to change the time I think I am covered.
I need someway of keeping track of the number that is "hours" and "minutes" so that the
if hour>=8 analogWrite(led1) {
for(int fadeValue = 0 ; fadeValue <=255; fadeValue +=5)
analogWrite(led1, fadeValue);
delay(30);}
function will fade on/off the LED
I'm not sure but it looks like that needs the computer time, this will be a stand alone system. I don't understand how to use it I tried the "time_t t = now();" and it gives me an error "time_t' was not declared in this scope".
Must admit I'm not understanding what you're on about so this maybe wrong but ...
// ... somewhere in global space ...
uint8_t seconds = 0; // range 0 - 255, 60 seconds in a minute
uint8_t minutes = 0; // range 0 - 255, 60 minutes in an hour
uint8_t hours = 0; // range 0 - 255, 24 hours in a day
uint16_t days = 0; // range 0 - 65535, (roughly) 365.25 days in a year
// ... somewhere in function, perhaps even 'loop', space ...
seconds++;
minutes += ((seconds %= 60) ? 0 : 1);
hours += ((minutes %= 60) ? 0 : 1);
days += ((hours %= 24) ? 0 : 1);
What it started as is there. There have been changes, or OP is wasting our time.
But noone has spelled out the changes required to the variables, which is clearly what is causing the problems, still. People mentioned it, but this one needs spoon feeding.
I put my whole code in the first post, and i figured it would be easier if I only quoted the section of code I need help with.
PaulS:
if (minute() ++ ((second() %= 60) ? 0 : 1);
You can't increment a function call.
is it still an if argument?
aarondc:
PaulS:
Check OP. It's all there.
What it started as is there. There have been changes, or OP is wasting our time.
But noone has spelled out the changes required to the variables, which is clearly what is causing the problems, still. People mentioned it, but this one needs spoon feeding.
I'm sorry I'm not good with writing code, we all have to start somewhere. c++ is new to me and I don't understand it. if I am too much of a pain to help I can got find a more welcoming forum
But noone has spelled out the changes required to the variables, which is clearly what is causing the problems, still. People mentioned it, but this one needs spoon feeding.
I'm sorry I'm not good with writing code, we all have to start somewhere. c++ is new to me and I don't understand it. if I am too much of a pain to help I can got find a more welcoming forum
I posted the change you need to make to get it to work. Did you see that post?