-
-
Save tonious/5522809 to your computer and use it in GitHub Desktop.
Azend's colour fader modified for a smooth progression using the power of trigonometry.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Diyode CodeShield Pinout Constants */ | |
#define ENCODER_A 14 | |
#define ENCODER_B 15 | |
#define ENCODER_PORT PINC | |
#define SWITCH 13 | |
#define BUTTON 12 | |
#define RGB_RED 11 | |
#define RGB_GREEN 10 | |
#define RGB_BLUE 9 | |
#define LED 6 | |
#define SERVO 5 | |
#define PIEZO 3 | |
#define RELAY 2 | |
#define POT 2 | |
#define HALL 3 | |
#define THERMISTOR 4 | |
#define PHOTOCELL 5 | |
double angle = 0; | |
void setup () { | |
pinMode( RGB_RED, OUTPUT ); | |
pinMode( RGB_GREEN, OUTPUT ); | |
pinMode( RGB_BLUE, OUTPUT ); | |
} | |
void loop () { | |
analogWrite( RGB_RED, byte( sin(angle) * 127 + 128)); | |
analogWrite( RGB_GREEN, byte( sin(angle + PI * 2/3) * 127 + 128 ) ); | |
analogWrite( RGB_BLUE, byte( sin(angle - PI * 2/3) * 127 + 128 ) ); | |
delay (15); | |
angle+= 0.01; | |
if( angle > PI * 2 ) angle = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment