So me and a friend are in a lab together, and we are working on a mini-project. The project involves creating and programming a circuit that can cycle through three button-states. The states are as follows:
Use the analogWrite command on pins 9 through 11 so Red, Green and Blue LEDs are set to a pulse width modulation (PWM) of 5.
After the button is pressed for the first time, the LEDs are to follow a pattern described in Table 1. Use PWM to set the intensity.
When the button is pressed the second time, all three lights will follow a pattern described in Table 2. When the intensity is to increase, colors decrease from 255 to 0 every 10 msec following a nonlinear increase of intensity calculated using Equation 1.
After the third button press, the lights should return to State 0. With each successive button press, the lights should step from one state to the next.
The circuit we have, as well as the code we have cobbled together, are attached below. Our issue is that we can (usually) get State 0 to work, but we can’t get our code and circuit to go to the next state or even reliably just show State 0. We’ve consulted the Interwebs and various resources at our university, but we can’t figure out. Any advice would be greatly appreciated. Thanks.
Mini_Project.ino (1.64 KB)