Pretty nooby, copying pasting and figuring it out as I go.
My project needs to run the following 4 Items to run some fun stuff in a puppet I'm making (ideally, one at a time with the option of all at once)
Momentary 5V power to a air pump that distributes smoke (joystick switch) & 2 Addressable LEDs running FastLED
FastLED code to 8 addressable LEDs (Joystick up)
FastLED code to 3 addressable LEDs (Joystick down)
Fade power to 2 LEDS (Left on Joystick)
Horns on the head will have a nice fire effect on trigger
Horns on the jaw will have similar
Eyes will glow red
Smoke through nose from pump with backlighting from Fastled.
I've started from the below to get the basics
At the moment I'm using an Arduino Nano. I assume I'm going to have to go to something bigger to run each of these indepentantly (or at the same time)
At the moment I have a test code setup with a Single LED to see my power on function (Smoke)
I also have 4 Leds set to trigger on Joystick Up (FastLED).
Problem I have at the moment is the lights flash periodically, ie don't stay on even with the joystick in the correct position and are quite dull. I assume I will need to be powering this with sometime more substantial to get it working.
This is my current code for the smoke (5v out) and 4 FastLeds. Not sure if being seperate like this is an issue or If I need to put all the options in a giant if / else statement.
At the moment I'm using an Arduino Nano. I assume I'm going to have to go to something bigger to run each of these indepentantly (or at the same time)
No, you only need one pin for all LEDs (they are addressable after all), a few pins for the joystick and one for the pump.
Problem I have at the moment is the lights flash periodically, ie don't stay on even with the joystick in the correct position and are quite dull. I assume I will need to be powering this with sometime more substantial to get it working.
You don't reset the LEDs if the joystick isn't in the Y-LOW position.
You set the brightness to about 2/3 of full power. As power and visible brightness aren't correlating linearly you probably get a bit less than half the maximum brightness they can give. As you did the program I must guess that this was your intention. Is that what you call dull?
As I mentioned I'm pretty new so nice pickups there now I know where to look.
I have now set brightness to 255 and moverd the FastLED.addleds into setup.
When you mention I only need a few pins for each are you suggesting the actual power itself is driver from another location while I simply use the Arduino to send the high / low signal?
Additionally, When you mention I don't reset the LEDs if the joystick isn't in the Y-Low position. How do I achieve that? IE what code do I need to focus on?
When you mention I only need a few pins for each are you suggesting the actual power itself is driver from another location while I simply use the Arduino to send the high / low signal?
I don't know what you meant by this sentence? Are we talking about the joystick or the LEDs?
Additionally, When you mention I don't reset the LEDs if the joystick isn't in the Y-Low position. How do I achieve that? IE what code do I need to focus on?
In the else part of this condition:
if (analogRead(Y_pin_in) < 50) {
you don't set anything in the FastLED part. So whatever is a left over of the Fire2012WithPalette() call will stay in the lights until you push the joystick in the same direction again.
pylon:
I don't know what you meant by this sentence? Are we talking about the joystick or the LEDs?
Sorry, My initial thoughts on the LEDs being so dim was answered by setting it to 150 instead of 255. I had a sneaky suspicion I wasn't giving them enough power.
In the else part of this condition:
if (analogRead(Y_pin_in) < 50) {
you don't set anything in the FastLED part. So whatever is a left over of the Fire2012WithPalette() call will stay in the lights until you push the joystick in the same direction again.
Sorry, still too new to understand that bit mind providing an example that would set the state to off once the joystick is released from a postion?
Thank you, I tried googling (clear / disable / stop FastLED) and din't have any luck. Knew it would be something like that.
Appreciate the assistance.
It appears the delay is the culprit when it comes to the LEDs only playing the animation momentarily:
if (analogRead(Y_pin_in) < 50) {
digitalWrite(Head_pin_out, HIGH); // turn the LED on by making the voltage HIGH
//FAST LED Add entropy to random number generator; we use a lot of it.
random16_add_entropy( random());
static uint8_t hue = 0;
hue++;
CRGB darkcolor = CHSV(hue,255,192); // pure hue, three-quarters brightness
CRGB lightcolor = CHSV(hue,128,255); // half 'whitened', full brightness
gPal = CRGBPalette16( CRGB::Black, darkcolor, lightcolor, CRGB::White);
Fire2012WithPalette(); // run simulation frame, using palette colors
FastLED.show(); // display this frame
FastLED.delay(1000 / FRAMES_PER_SECOND);
}
// -=HORNS OFF=-
else {
FastLED.clear(true);
digitalWrite(Head_pin_out, LOW); // turn the LED off (LOW is the voltage level)
I did change the Delay to a much larger number which at least got the LEDS to stay lit longer, however I'm wanting them to pretty much loop until the Y axis is again released. Any ideas?
It appears the delay is the culprit when it comes to the LEDs only playing the animation momentarily:
I don't think so, but it may be that you're interpreting it's function not correctly.
I did change the Delay to a much larger number which at least got the LEDS to stay lit longer, however I'm wanting them to pretty much loop until the Y axis is again released. Any ideas?
If you want the animation to be slower, decrease the FRAMES_PER_SECOND value.
The animation will loop automatically as long as the joystick is in that position. If that's not the case there might be an error in the circuit.