Hi, everybody. Doing some playing around getting my project to work properly: Osepp Uno R3 plus, trying to use two pots to run two Adafruit neopixel rings (12 pixels each). I've been trying to get them set up so each pot controls each ring. I managed to get as far as each one sweeping their preferred color ranges, but each pot input pin seems to control both rings at the same time. I even assigned each pot their own pin in the program.
Here's what I used. It's actually modified from another one I found on here:
#include <Adafruit_NeoPixel.h>
#define PIN1 2 //You might need to change this depending on what pins your board has. These means you should connect the ring's 'data in' to digital pin 2 on the arduino.
#define PIN2 4
//Initialize the ring. In the line below I used "12" since you mentioned a ring of 12 LEDs. If not then change it to however many LEDs you have.
Adafruit_NeoPixel ring1 = Adafruit_NeoPixel(12, PIN1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel ring2 = Adafruit_NeoPixel(12, PIN2, NEO_GRB + NEO_KHZ800);
int potpin = A0; //This is the value you will change based on your potentiometer values once you get that working too.
int potpin2 = A1;
void setup() {
ring1.begin();
ring1.show(); // Initialize all pixels to 'off'
potpin = 0;
pinMode(A0, INPUT);
ring2.begin();
ring2.show(); // Initialize all pixels to 'off'
potpin2 = 1;
pinMode(A1, INPUT);
}
void loop() {
int reading = analogRead(A0); //Adafruit trinket oddity, usually the same as pinMode
potpin = (int)(reading * 12 / 1024); //potentiometer specific values, adjust until entire ring is filled
//Turn on correct number of LEDs based on numOn
for (int i = 0; i < 12; i++) {
if (i < potpin+1) { //the +1 keeps one LED on at all times
ring1.setPixelColor(i, 100, 0, 0); // turn on this LED, also adjusts colors ); //turn on this LED, adjust values to affect colors and brightness of LEDs
}
else {
ring1.setPixelColor(i, 0, 0, 100); //turn off this LED
}
ring1.show(); //Apply changes to Ring
int reading = analogRead(A1); //Adafruit trinket oddity, usually the same as pinMode
potpin2 = (int)(reading * 12 / 1024); //potentiometer specific values, adjust until entire ring is filled
//Turn on correct number of LEDs based on numOn
for (int i = 0; i < 12; i++) {
if (i < potpin2+1) { //the +1 keeps one LED on at all times
ring2.setPixelColor(i, 0, 100, 0); // turn on this LED, also adjusts colors ); //turn on this LED, adjust values to affect colors and brightness of LEDs
}
else {
ring2.setPixelColor(i, 100, 100, 100); //turn off this LED
}
ring2.show(); //Apply changes to Ring
}
}
}
Any idea what I'm doing wrong? I'm sure my eyes are just strained and I just can't see something obvious...