Skip to content

Instantly share code, notes, and snippets.

@azend
Last active December 11, 2015 21:48
Show Gist options
  • Save azend/4665035 to your computer and use it in GitHub Desktop.
Save azend/4665035 to your computer and use it in GitHub Desktop.
Simple fade up using different colors on an rgb led. Works by overflowing the unsigned char until it rolls over.
/* 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
unsigned char redBrightness = 0;
unsigned char greenBrightness = round( 255 / 3.0f );
unsigned char blueBrightness = round( 255 / 3.0f ) * 2;
void setup () {
pinMode( RGB_RED, OUTPUT );
pinMode( RGB_GREEN, OUTPUT );
pinMode( RGB_BLUE, OUTPUT );
}
void loop () {
redBrightness ++;
greenBrightness ++;
blueBrightness ++;
analogWrite( RGB_RED, redBrightness );
analogWrite( RGB_GREEN, greenBrightness );
analogWrite( RGB_BLUE, blueBrightness );
delay (15);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment