Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Softly twinkling lights for Teensy 2.0++
int ledPin1 = 27;
int ledPin2 = 0;
int ledPin3 = 1;
int ledPin4 = 14;
int ledPin5 = 15;
int ledPin6 = 16;
int ledPin7 = 24;
int ledPin8 = 25;
int ledPin9 = 26;
void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin8, OUTPUT);
pinMode(ledPin9, OUTPUT);
}
void loop()
{
float something = millis()/5000.0;
int v1 = 128.0 + 128 * sin( something * 2.0 * PI );
int v2 = 128.0 + 128 * sin( (something+0.05) * 2.0 * PI );
int v3 = 128.0 + 128 * sin( (something+0.1) * 2.0 * PI );
int v4 = 128.0 + 128 * sin( (something+0.15) * 2.0 * PI );
int v5 = 128.0 + 128 * sin( (something+0.2) * 2.0 * PI );
int v6 = 128.0 + 128 * sin( (something+0.25) * 2.0 * PI );
int v7 = 128.0 + 128 * sin( (something+0.3) * 2.0 * PI );
int v8 = 128.0 + 128 * sin( (something+0.35) * 2.0 * PI );
int v9 = 128.0 + 128 * sin( (something+0.4) * 2.0 * PI );
analogWrite(ledPin1,v1);
analogWrite(ledPin2,v2);
analogWrite(ledPin3,v3);
analogWrite(ledPin4,v4);
analogWrite(ledPin5,v5);
analogWrite(ledPin6,v6);
analogWrite(ledPin7,v7);
analogWrite(ledPin8,v8);
analogWrite(ledPin9,v9);
}
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.