Hi
I am trying to use a Potentiometer to control the back and forth movement of an individual pixel or group of pixels (say 10) on a neopixel strip. I have been trying for days.
Any help would be greatly appreciated!
Thank you so much,
Cory
Hi
I am trying to use a Potentiometer to control the back and forth movement of an individual pixel or group of pixels (say 10) on a neopixel strip. I have been trying for days.
Any help would be greatly appreciated!
Thank you so much,
Cory
What have you tried?
I was able to get pixels to grow from any point in either direction so it just fills in with lit pixels and when I turn the potentiometer the other way they erase in that direction.
I just seem to be lost on how to get a pixel or a group to move in either direction.
????
Thanks
ctclown:
I was able to get pixels to grow from any point in either direction so it just fills in with lit pixels and when I turn the potentiometer the other way they erase in that direction.
I just seem to be lost on how to get a pixel or a group to move in either direction.????
Thanks
Post the code you have tried!
this is un tested but something like this may work....
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_PIXELS 16
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
const byte potPin = A4;
int litPixel = -1;
void setup()
{
pixels.begin(); // This initializes the NeoPixel library.
}
void loop()
{
int newPixel = map(analogRead(potPin), 0, 1023, 0, NUM_PIXELS);
if (newPixel != litPixel)
{
for (int i = 0; i < NUM_PIXELS; i++)
{
pixels.setPixelColor(i, (i == newPixel)? pixels.Color(255, 255, 255) :pixels.Color(0, 0, 0));
}
pixels.show(); // This sends the updated pixel color to the hardware.
litPixel = newPixel;
}
}
Any help would be greatly appreciated!
You have some code. Apparently it does something that is not exactly what you want. What that code looks like, what it actually does, and how that differs from what you want are all mysteries. I hate mysteries, except murder mysteries.
Bulldoglowell
I had got something going but I think yours is much better!
Thank you very much. I will have to start playing with yours and see if I can add what I need.
Thanks Again
Cory
Bulldoglowell
I was able to turn the background color to anything I want which is really great. I tried to get the one moving pixel to be around ten but had no luck. I also tried to turn down the Brightness.
WOW! It is close Thank You So. . . So. . . Much!!!!!
Cory
Bulldoglowell
Just figured out the brightness.
Cory
ctclown:
BulldoglowellJust figured out the brightness.
Cory
you should post your final solution.
Hi,
Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
Thanks... Tom... ![]()
TomGeorge
Thanks
This is the sketch that Bulldoglowell gave me. I was able to put in a brightness control.
It seems a lot simpler then the one I was making but I need the led to be a cluster of maybe 10 or more as a group.
I am not able to figure out how to make Bulldoglfowell's sketch achieve this.
On a Second potentiometer I'm going to need pixels to grow out from a designated pixel in both directions so that they can expand and contract to the same spot on the same strip as the culture above.
The sketch that I was writing, is writing and subtracting pixels line by line. The finished sketch would be huge. Bulldog's sketch obviously uses the power of the program.
Thank you for your time
Lost but learning,
Cory
EyE_Move_Start.ino (705 Bytes)
you should only ve calling this in setup():
pixels.setBrightness(10);
ctclown:
On a Second potentiometer I'm going to need pixels to grow out from a designated pixel in both directions so that they can expand and contract to the same spot on the same strip as the culture above.
you can try something like this untested and not for a circle!
#include <Adafruit_NeoPixel.h>
#define PIN 5
#define NUM_PIXELS 31
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
const byte potPin = A0;
const byte potPin2 = A1;
int litPixel = (6);
int lastCenter = -1;
int lastStretch = -1;
void setup()
{
pixels.begin();
pixels.setBrightness(10);
}
void loop()
{
int centerPixel = map(analogRead(potPin), 0, 1023, 0, NUM_PIXELS);
int stretch = map(analogRead(potPin2), 0, 1023, 0, NUM_PIXELS / 2);
if(centerPixel != lastCenter || stretch != lastStretch)
{
ledStripUpdate(centerPixel, stretch);
lastStretch = stretch;
lastCenter = centerPixel;
}
}
void ledStripUpdate(int center, int ditherWidth)
{
static int lastCenter = -1;
for (int i = 0; i < NUM_PIXELS; i++)
{
if (i < center - ditherWidth)
{
pixels.setPixelColor(i, pixels.Color(100, 0, 100));
}
else if (i < center)
{
byte fadenum = constrain(map(i, center - ditherWidth, center, 0, 255), 0, 255);
pixels.setPixelColor(i, pixels.Color(fadenum, fadenum, fadenum));
}
else if (i == center)
{
pixels.setPixelColor(i, pixels.Color(255, 255, 255));
}
else if (i < center + ditherWidth)
{
byte fadenum = constrain(map(i, center, center + ditherWidth, 255, 0), 0, 255);
pixels.setPixelColor(i, pixels.Color(fadenum, fadenum, fadenum));
}
else
{
pixels.setPixelColor(i, pixels.Color(100, 0, 100));
}
pixels.setPixelColor(i, (i == center) ? pixels.Color(255, 255, 255) : pixels.Color(100, 0, 100));
}
pixels.show();
}
but, you probably want to dither it into this color: pixels.Color(100, 0, 100) I'll leave it to you to solve that!
Are your pixels in a ring?
BullDog
Thanks
potpin2 sketch seems to not do anything, I tried switching potPin and potPin2 and both of my potentiometer's are working but nothing seems to be happening with.
int stretch = map(analogRead(potPin2), 0, 1023, 0, NUM_PIXELS / 2);
potPin is moving the one pixel around fine. I tried to find what's broken for "stretch" but I'm not sure if that is what I'm supposed to be looking for.
Thank you so much for your help and time.
Cory
BullDog
P.S.
My pixels are not in a ring it will ultimately end up in a 119 pixel strip.
I am using a 31 pixel strip for testing.
Cory