diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2018-11-02 12:37:09 +0100 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2018-11-02 12:37:09 +0100 |
commit | 222105e04e15f27ec56d1c92fe9671e5d8ab9be8 (patch) | |
tree | 1ea16b8d42450fd89a3c7815875980b2a4790e8d | |
parent | 9d8461c5ae9b7f2aee31b5426d03932ca76392c1 (diff) | |
download | Stickman-Costume-222105e04e15f27ec56d1c92fe9671e5d8ab9be8.tar.gz Stickman-Costume-222105e04e15f27ec56d1c92fe9671e5d8ab9be8.zip |
:sparkles: Finished four modes, and mode-changinig button
-rw-r--r-- | Stickman-Costume.ino | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/Stickman-Costume.ino b/Stickman-Costume.ino index d05e645..4edf99b 100644 --- a/Stickman-Costume.ino +++ b/Stickman-Costume.ino @@ -7,23 +7,23 @@ * 3 Fast Strobe */ #define OUT_PWM 1 // The LED-strip is connected to PB1 -#define IN_MODE 2 // Pressing this increments 'mode' by one +#define IN_MODE 4 // Pressing this increments 'mode' by one #define IN_ADJ 3 // This button adjusts the brightness -int CMode = 0; // This is just the current mode +int CMode = 2; // This is just the current mode int ExistingModes = 4; // This is the number of modes that are implemented // Used for saving button state bool IN_ADJ_STATE = false; // bool IN_MODE_STATE = false; // // These are for the general pwm-frequency (not all modes care) -int CBrightness = 50; // The brightness of the strip, between '0' and '255' +int CBrightness = 255; // The brightness of the strip, between '0' and '255' int CDimDirection = 0; // Used to know if the brightness should be increasing or decreasing based on the button press // These are used by the strobe-effect int CStrobeRevs = 0; // A running counter for the strobe-light int StrobeState = 0; // '0' or '1' for saving the state of the output -int StrobeSlowFreq = 1024; -int StrobeMedFreq = 600; -int StrobeFastFreq = 200; +int StrobeSlowFreq = 70; +int StrobeMedFreq = 30; +int StrobeFastFreq = 5; void setup() { @@ -35,7 +35,7 @@ void setup() { /* loop * * it takes aprox. ?ms to run through the loop once, whitout changing pwm freq - */ + */ void loop() { delay(1); @@ -53,11 +53,11 @@ void loop() { if (CBrightness >= 255) { CDimDirection = 0; } if (CBrightness <= 0) { CDimDirection = 1; } } - + // Do animation-things switch (CMode) { case 0: // Static - analogWrite(OUT_PWM, CBrightness); + analogWrite(OUT_PWM, CBrightness); break; case 1: // Slow Strobe @@ -100,8 +100,7 @@ void strobe() { if (StrobeState == 1) { StrobeState = 0; setOutPwm(0); - } - if (StrobeState == 0) { + } else if (StrobeState == 0) { StrobeState = 1; setOutPwm(CBrightness); } |