-
Notifications
You must be signed in to change notification settings - Fork 3
/
rgb1.ino
85 lines (75 loc) · 2.72 KB
/
rgb1.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 4 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 1 // Popular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
// The first NeoPixel in a strand is #0, second is 1, all the way up
// to the count of pixels minus one.
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// Here we're using a moderately bright green color:
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(0,0,i));
pixels.show();
delay(DELAYVAL);
}
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(0,i,0));
pixels.show();
delay(DELAYVAL);
}
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(i,0,0));
pixels.show();
delay(DELAYVAL);
}
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(0,i,i));
pixels.show();
delay(DELAYVAL);
}
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(i,0,i));
pixels.show();
delay(DELAYVAL);
}
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(i,i,0));
pixels.show();
delay(DELAYVAL);
}
for(int i=0; i<256; i+=16) // For each pixel...
{
pixels.setPixelColor(0, pixels.Color(i,i,i));
pixels.show();
delay(DELAYVAL);
}
}