#EDIT: Controlling multiple LEDS with the propmaker and neokeys
1 messages · Page 1 of 1 (latest)
Hey, so I'm starting a thread for this as not to clog up the main chat. I'm currently trying to control multiple servos with a propmaker. I have built a keyboard using 8 neokeys that plays a fart SFX when you hit a key. I had the idea that as the key is pressed a servo makes a 3D printed figure bounce off a toilet when the key is pressed and fall back when released. 8 figures in total, one for each key. I have 8 servos and a servo controller attached above. I have yet to master servos so I do need help getting it all working. Firstly, looking at the pics above did I hook it up right? the one servo I have hooked up moved a bit, and the power light on the controller is lit up.
I only had a 12V supply for the controller and noticed a slight bit of head on the servo. It says 5V so should i get a 5V supply instead?
If your servo is rated for 5V -- which they typically are -- yes, you should power it from 5V.
Beware that connecting it to 12V might have already damaged the servo.
The 5V pin on the terminal block of your prop maker feather is a high current power pin ( it's meant to power neopixels)
https://learn.adafruit.com/adafruit-rp2040-prop-maker-feather/pinouts#terminal-block-pins-neopixel-button-and-speaker-3147627
You could use that pin to power a couple of servos for testing until you get a separate 5V power supply
( I am not sure if it can handle 8 servos like you need, so probably don't try with all of them )
Ooo thankfully I only plugged in 1 servo for testing
I ordered a 5V
Here is an 8-channel servo FeatherWing you can attach to the Prop-Maker: https://www.adafruit.com/product/2928
A Feather board without ambition is a Feather board without FeatherWings! This is the 8-Channel PWM or Servo FeatherWing, you can add 8 x 12-bit PWM outputs to your Feather board. ...
You can attach it with stacking headers on top of the Prop-Maker, or you can use a https://www.adafruit.com/product/2890, which is out of stock on our site, unfortunately, but is in stock at Digi-Key. Also there are triplers, https://www.adafruit.com/product/3417, and quads
This is the FeatherWing Doubler - a prototyping add-on and more for all Feather boards. This is similar to our FeatherWing Proto except there are two! The magic of the Doubler comes when ...
https://cdn.discordapp.com/attachments/330406777009209346/1323382494799593644/IMG_3463.jpg?ex=6775a0fe&is=67744f7e&hm=78a4c919c263689691946f2595182471375d3d7244bc67738654d112c244550f&I I already have this, but is this one you linked better?
that is fine, the FeatherWing board is similar, and just avoids needing to run some wires, which you already did.
Yeah and I kinda need the wires so I can spread out the servos
Or rather fit it in the enclosure
My 5V supply is arriving today
So when it does I’m going to need help figuring out controlling it
ok my power supply arrived, so i can start trying to figure out the servos. here's the code that i'm currently using in circutpython
I also 3D printed one of the parts for testing
first thing i have to do is get the servo control working
then i can work on linking the 2
The idea was when you hold down the neokey, the noise plays until you let go then it stops. That is currently setup. (thanks to @half drum for helping me with that) The next step is to add a function that moves the servo when the key is held down then when the key is released the servo moves back to its original position
https://learn.adafruit.com/cardboard-slider-crank I also have to build this as well
Here’s where the finished figures will go
Just to give you an idea
I’m still trying to figure out the servos
Ok so I have a much less impressive/simple idea. Instead of servos, LED bulbs that light up in the window like an old love tester
I found out the servo controller I got also works with LEDS
So I can still use that
EDIT: Controlling multiple LEDS with the propmaker and neokeys
Just edited the thread as not to start another one
https://www.adafruit.com/product/4980 I asked this in the projects forum but is there any way to solder/attach external wired LEDS to each key so they can illuminate outside of the board. The code for lights is already in the neo key circutpython code (currently tuened off) but its directly under each key
The only thing better than a nice mechanical key is, perhaps, FOUR mechanical keys that also can glow any color of the rainbow - and that's what the Adafruit NeoKey 1x4 QT I2C ...
I have this which can also control LEDs but not sure how to code it so the prop maker recognizes it
I DO have a spare neokey
Which I could experiment with
But any advice/guidance would be a help
if you unplug one of the switches you can see the NeoPixel underneath. Since the switch body is clear, a light source in the back somewhere will show through. If you want to use a NeoKey, then you don't need the servo board: just run a STEMMA cable to the NeoKey and see its guide for examples
If you want to use some other LED, you can just tape or glue it to the back of the switch. Mounting the switch is the hard part. Or you can snap it into a hole and solder to the terminals
we sell pushbuttons with LEDs inside but they are pretty big: 16mm minimum
Do you have a visual example of this method
no, but just hold a switch in front of an LED
have you tried using the neokey?
I mean just to try it out
One sec
same idea on a macropad, if you have one
When you say switch do you mean the neokey board or this:
I assume you mean the board itself
the first - the bare switch. All I mean is the plastic is clear, which is how it lights up.
If your project could use two NeoKey's, that's a solution, but maybe they're too big
Here’s my project: I want this keyboard (when a key is pressed) to play a sound (which it currently does thanks to your help a while back) but I want each key to light up one of those bulbs in the enclosure
I was wondering initially if I could just wire LEDs on long wires to each key but looking at it it seems I don’t have room in there
I guess I have to do it in circuit python
Through the prop maker
Then use the other board to connect the LEDs
def get_pressed_button_number():
# Get all the button states and concatenate into one list.
button_states = neokey1.get_keys() + neokey2.get_keys()
# If they are all False, return None
if not any(button_states):
return None
# Get the first pressed button (the first True in the list)
return button_states.index(True)
def set_button_color(button_number, color):
# Choose which neokey to use based on the range: 0-3 or 4-7.
if button_number <= 3:
neokey1.pixels[button_number] = color
else:
neokey2.pixels[button_number - 4] = color
# Play the selected file.
def play_file(filename, current_button_number):
print("Playing", filename)
with open(f"/sounds/{filename}", "rb") as file:
audio.play(audiocore.WaveFile(file))
while audio.playing:
# Did a different button get pressed?
if get_pressed_button_number() != current_button_number:
audio.stop()
return``` in code, the only thing I have a hunch on is the LED code would go in the middle somewhere
# Choose which neokey to use based on the range: 0-3 or 4-7.
if button_number <= 3:
neokey1.pixels[button_number] = color
else:
neokey2.pixels[button_number - 4] = color
I THINK I have to edit this part
so you want both the keys and the separate LED's to light up?
you're not actually using neokeys for this project, right?
Well each piano key is attached to one of the Neokeys
i see
these are attached to a propmaker board with a speaker
And the propmaker is attached to this controller which I read can control LEDs too
well, you could put a NeoPixel strip behind the holes in the printed menu board, or put individual LEDs there, or individual NeoPixel LEDs. You could use something like Lite-Brite Pins in the holes to let the light through. Or the NeoPixel "globe" LED's I linked to earlier. Or wire a resistor to each LED and connect them to the servo boards outputs
do you have some LED's already?
but you don't like how they look if you put them in the holes?
so you are just wondering about how to turn them on with the servo board?
Yes
which board is this again?
the servo controller?
yes
this one
basically
i had it in my bin of parts
you can use the https://github.com/adafruit/Adafruit_CircuitPython_PCA9685 library. See https://github.com/adafruit/Adafruit_CircuitPython_PCA9685/blob/main/examples/pca9685_simpletest.py, which will turn on the 0 pin at half brightness (due to duty_cycle = 0x7ff).
I'd increase the .frequency to something higher like 1000 so you wont see flicker.
to turn an LED, set the duty_cycle to something non-zero. to turn it off, set the duty_cycle to zero
I'll futz around with this to see if I can figure it out
i am going shopping
ok, getting somewhere i think. the controller is connected to the propmaker sucessfully (I was getting an error but managed to figure out I had the wires wrong so i fixed it)
https://learn.adafruit.com/16-channel-pwm-servo-driver/python-circuitpythonI also found this which has a section on "Dimming LEDS"
its a matter of editing the currenct code. i have 1 led wired as a test
I ALMOST GOT IT
I got it so when I press a key the led lights up then when i release the led shuts off. I now need to figure out how to to get each key to light a seperate led on a different channel on the servo controller
Here's the updated code
0x000000,
0x000000,
0x000000,
0x000000,
0x000000,
0x000000,
0x000000,
0x000000,
]
``` I think I have to edit these values but I'm not sure
while True:
# May be None, if no button pressed
button_number = get_pressed_button_number()
pca.channels[button_number].duty_cycle = 0
if button_number is not None:
# Light up the chosen button.
set_button_color(button_number, BUTTON_COLORS[button_number])
pca.channels[button_number].duty_cycle = 0x7FFF # change value to change brightness
# Play the chosen sound. If another button is pressed, stop early.
play_file(FILES[button_number], button_number)
set_button_color(button_number, 0)
You can take away all the set_button_color() if you don't want the NeoKeys to light up.
It gave me an error saying “list indices must be integers not Nonetype” on the line “pca.channels[button_number]
you don't care about the neokey colors, right? I'll remove that code.
removed unneeded code, fixed error
Yeah I don’t need the neokey color
I’ll check this code out in a sec
Thank you again