Type here. Use Markdown, BBCode, or HTML to format. Drag or paste images.
Before you code it, refine your problem definition.
There are two parts that are more or less independent, that you need to design:
- detect the state of light/darkness
- detect a transition between light and dark (not just the state of light/darkness).
There is also
3. increment the brightness level on a transition
But it is trivial if you have #2 coded already.
Have a look at this: switch...case - Arduino Reference
It's excellent to use when creating sequences.
Such vague, general language is not helpful for people who might help solve your problem. We need a clear, detailed explanation of what the program is supposed to do, what your posted code does, and what the precise differences between those are.
Just make each state do what You want. If You could provide a block diagram of the action You want, or flowcharts, You might get better suggestions.
Just using Shakespeare is not good enough.
I doubt that very much, as it would be one line of code. I think, your issue might be detecting a transition in the first place.
if (brightness++ >= brightnessLevels) brightness = 0;
So les say you have a variable thingy that gets incremented every time the thingy is tapped.
int mytaptunecountthingy = 0;
voiding tapTune()
{
if (this is a tap then)
{mytaptunecounthingy++;}
if mytaptunecountthingy ==0 make lights x0 bright
if mytaptunecountthingy ==1 make lights x1 bright
if mytaptunecountthingy ==2 make lights x2 bright
if mytaptunecountthingy >5 mytaptunecountthingy =0;
}
or something like that.
Please don't make changes to previous posts. It makes the thread confusing to follow.
Okay. I've read your objectives. It's more concise and understandable than your paragraph description. But it doesn't really add any information. The assignment (from school, no doubt) is clear. What is not clear, is what design steps you have made to implement the objectives.
You also have to respond meaningfully to suggestions and ideas that have been posted.
@anon69441495 has been banned due to thread vandalism.