Skip to content

Instantly share code, notes, and snippets.

@skynettw skynettw/arduino-unit-4-2
Last active Dec 24, 2017

Embed
What would you like to do?
int LEDRpin = 3;
int LEDGpin = 5;
int LEDBpin = 6;
void turn(int r, int g, int b) {
analogWrite(LEDRpin, r);
analogWrite(LEDGpin, g);
analogWrite(LEDBpin, b);
}
void setup() {
pinMode(LEDRpin, OUTPUT);
pinMode(LEDGpin, OUTPUT);
pinMode(LEDBpin, OUTPUT);
turn(0, 0, 0);
}
void loop() {
for(int i=0; i<256; i++)
{
turn(i, i, i);
delay(5);
}
for(int i=255; i>0; i--) {
turn(i, i, i);
delay(5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.