Skip to content

Instantly share code, notes, and snippets.

@limpid-kzonix
Created May 26, 2019 17:45
Show Gist options
  • Save limpid-kzonix/c0efd509da9d3bc5cd0465b64c5ed778 to your computer and use it in GitHub Desktop.
Save limpid-kzonix/c0efd509da9d3bc5cd0465b64c5ed778 to your computer and use it in GitHub Desktop.
Arduino FE-RGB
#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