Skip to content

Commit 0c8ed05

Browse files
committed
Add inclination demonstration
1 parent 3c62dfc commit 0c8ed05

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
INC_Orientation_Test.ino
3+
4+
This sketch provides a way for you to ensure that the inclination ring is
5+
mounted correctly and that you know the correct value to set for the INCREF
6+
variable. INCREF should be set to the pixel number that is just above horizontal
7+
in the +y direction.
8+
9+
Created: 10/30/14
10+
Author: John R. Leeman
11+
Modified: 10/31/14
12+
www.johnrleeman.com
13+
www.github.com/jrleeman
14+
*/
15+
16+
17+
#include <Adafruit_NeoPixel.h>
18+
#include <Wire.h>
19+
20+
#define PIXILPIN 13 // Pin on the Arduino that the NeoPixil chain is connected to
21+
#define NUMAZ 24 // Number of pixels on the azimuth ring
22+
#define NUMINC 16 // Number of pixels on the inclination ring
23+
24+
#define INCREF 11 // Pixil Number that is above the +y axis direction
25+
26+
int incPixel = 0; // Stores pixel that was turned on
27+
28+
// Setup neopixels
29+
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMAZ + NUMINC, PIXILPIN, NEO_GRB + NEO_KHZ800);
30+
31+
void setup() {
32+
33+
// Start strip and make all pixels dark
34+
strip.begin();
35+
strip.show();
36+
37+
// Start the serial port and write description
38+
Serial.begin(115200);
39+
Serial.println("Inclination Ring Orientation Test");
40+
Serial.println("");
41+
Serial.println("The INCREF definition should be setup for the pixel that is");
42+
Serial.println("located just above horizontal in the +y direction.");
43+
Serial.println("");
44+
Serial.println("This should run through an 8 element pattern, to check ring");
45+
Serial.println("orientation. First all lights will turn on, then off. Ring");
46+
Serial.println("will then cycle through below/above horizontal in the +y direction,");
47+
Serial.println("then around vertical, then above/below horizontal in the -y direction,");
48+
Serial.println("and finally around vertical downwards.");
49+
50+
// Flash the entire ring
51+
allOn();
52+
delay(2000);
53+
allOff();
54+
delay(1000);
55+
}
56+
57+
void loop() {
58+
// 350 Degrees
59+
plotInclination(350);
60+
delay(1000);
61+
62+
// 10 Degrees
63+
plotInclination(10);
64+
delay(1000);
65+
66+
// 80 Degrees
67+
plotInclination(80);
68+
delay(1000);
69+
70+
// 100 Degrees
71+
plotInclination(100);
72+
delay(1000);
73+
74+
// 170 Degrees
75+
plotInclination(170);
76+
delay(1000);
77+
78+
// 190 Degrees
79+
plotInclination(190);
80+
delay(1000);
81+
82+
// 260 Degrees
83+
plotInclination(260);
84+
delay(1000);
85+
86+
// 280 Degrees
87+
plotInclination(280);
88+
delay(1000);
89+
90+
// All off and wait
91+
allOff();
92+
delay(2000);
93+
}
94+
95+
void plotInclination(float angle){
96+
// Plot a single pixel at the angle provided.
97+
98+
// Turn off old pixel
99+
strip.setPixelColor(incPixel, 0,0,0);
100+
101+
// Calculate new pixel number
102+
incPixel = (angle-(360/NUMINC/2)) / (360/NUMINC);
103+
104+
// Rotate to correct for ring orientation
105+
incPixel = INCREF - incPixel;
106+
107+
if (incPixel < 0){
108+
incPixel = NUMINC + incPixel;
109+
}
110+
111+
incPixel += NUMAZ;
112+
113+
// Turn on the new pixel
114+
strip.setPixelColor(incPixel, 50,0,0);
115+
strip.show();
116+
}
117+
118+
void allOn() {
119+
// Turn on all inclination pixels
120+
for (int i=NUMAZ; i<NUMAZ+NUMINC; i++){
121+
strip.setPixelColor(i,20,20,20);
122+
}
123+
strip.show();
124+
}
125+
126+
void allOff() {
127+
// Turn off all inclination pixels
128+
for (int i=NUMAZ; i<NUMAZ+NUMINC; i++){
129+
strip.setPixelColor(i,0,0,0);
130+
}
131+
strip.show();
132+
}
133+
134+
135+

0 commit comments

Comments
 (0)