Created
May 26, 2019 17:45
-
-
Save limpid-kzonix/c0efd509da9d3bc5cd0465b64c5ed778 to your computer and use it in GitHub Desktop.
Arduino FE-RGB
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
#include <Arduino.h> | |
int redPin = 3; | |
int greenPin = 5; | |
int bluePin = 6; | |
#define COMMON_ANODE | |
void setup() | |
{ | |
pinMode(redPin, OUTPUT); | |
pinMode(greenPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
} | |
void setColor(int red, int green, int blue) | |
{ | |
int swap_red = blue; | |
int swap_blue = red; | |
#ifdef COMMON_ANODE | |
red = 255 - swap_red; | |
green = 255 - green; | |
blue = 255 - swap_blue; | |
#endif | |
analogWrite(redPin, red); | |
analogWrite(greenPin, green); | |
analogWrite(bluePin, blue); | |
} | |
void loop() | |
{ | |
setColor(255, 0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment