My 8 LEDs can work by connecting to Seed through 4021, but I found that the status of the LEDs is reversed from the settings in PD. When I set 1, the LED goes out, and when I set 0, the LED lights up. I have to use [-1] - [abs] to reverse it every time. How can I solve this problem? Is it useful to modify the definition of JSON? Or is there any other way?
What does your JSON currently look like?
Using a CD4021 for LEDs is a little bit odd though. On the Field for instance it is used to attach multiple switches: hvcc/hvcc/generators/c2daisy/json2daisy/resources/field.json at develop · Wasted-Audio/hvcc · GitHub
Sorry, it’s my fault. I’ve been a little confused recently. My LEDs are directly connected to Seed’s D0-D7 pins, and 4021 is connected to buttons. Here is my JSON.
Are the LEDs connected to ground, or to +3.3?
Please share the complete json as an inline code-block. This doesn’t really help to review what you are doing.
Okay, my LED negative pin is directly connected to Seed’s D0-D8, and the positive pin is connected in series with a 220R resistor to digital ground. Did I take the wrong answer? Below is my complete JSON.
{
"name": "customseed",
"som": "seed",
"defines": {
"OOPSY_TARGET_HAS_MIDI_INPUT": 1
},
"audio": {
"channels": 2
},
"parents": {
"pot_mux1": {
"component": "CD4051",
"mux_count": 8,
"pin": {
"adc": 15,
"sel0": 19,
"sel1": 20,
"sel2": 21
}
},
"pot_mux2": {
"component": "CD4051",
"mux_count": 8,
"pin": {
"adc": 16,
"sel0": 22,
"sel1": 23,
"sel2": 24
}
},
"button_shift": {
"component": "CD4021",
"pin": {
"clk": 25,
"cs": 26,
"data": 27
}
}
},
"components": {
"knob1": {
"component": "CD4051AnalogControl",
"index": 0,
"parent": "pot_mux1"
},
"knob2": {
"component": "CD4051AnalogControl",
"index": 1,
"parent": "pot_mux1"
},
"knob3": {
"component": "CD4051AnalogControl",
"index": 2,
"parent": "pot_mux1"
},
"knob4": {
"component": "CD4051AnalogControl",
"index": 3,
"parent": "pot_mux1"
},
"knob5": {
"component": "CD4051AnalogControl",
"index": 4,
"parent": "pot_mux1"
},
"knob6": {
"component": "CD4051AnalogControl",
"index": 5,
"parent": "pot_mux1"
},
"knob7": {
"component": "CD4051AnalogControl",
"index": 6,
"parent": "pot_mux1"
},
"knob8": {
"component": "CD4051AnalogControl",
"index": 7,
"parent": "pot_mux1"
},
"knob9": {
"component": "CD4051AnalogControl",
"index": 0,
"parent": "pot_mux2"
},
"knob10": {
"component": "CD4051AnalogControl",
"index": 1,
"parent": "pot_mux2"
},
"knob11": {
"component": "CD4051AnalogControl",
"index": 2,
"parent": "pot_mux2"
},
"knob12": {
"component": "CD4051AnalogControl",
"index": 3,
"parent": "pot_mux2"
},
"knob13": {
"component": "CD4051AnalogControl",
"index": 4,
"parent": "pot_mux2"
},
"knob14": {
"component": "CD4051AnalogControl",
"index": 5,
"parent": "pot_mux2"
},
"knob15": {
"component": "CD4051AnalogControl",
"index": 6,
"parent": "pot_mux2"
},
"knob16": {
"component": "CD4051AnalogControl",
"index": 7,
"parent": "pot_mux2"
},
"button1": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 0
},
"button2": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 1
},
"button3": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 2
},
"button4": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 3
},
"button5": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 4
},
"button6": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 5
},
"button7": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 6
},
"button8": {
"component": "CD4021Switch",
"parent": "button_shift",
"index": 7
},
"led1": {
"component": "Led",
"pin": 0
},
"led2": {
"component": "Led",
"pin": 1
},
"led3": {
"component": "Led",
"pin": 2
},
"led4": {
"component": "Led",
"pin": 3
},
"led5": {
"component": "Led",
"pin": 4
},
"led6": {
"component": "Led",
"pin": 5
},
"led7": {
"component": "Led",
"pin": 6
},
"led8": {
"component": "Led",
"pin": 7
}
}
}
Yes,he LEDs connected to ground and +3.3v
LEDs are usually wired between an IO pin and ground, OR between an IO pin and +3.3.
It can work either way, but the polarity would be inverted.
So can I directly reverse the positive and negative poles of the LED?
Sorry I totally missed this, so you didn’t use the CD4021 for the LEDs at all ![]()
You still haven’t shown precisely how the LEDs are wired, but whether they are active high or active low is determined by whether they are wired to +3.3 or to ground. Also, you wrote above that the LEDs are connected to 3.3 and ground, which is definitely incorrect.
I described my configuration incorrectly, sorry.
LED has two pins, the longer pin is the positive pole and the shorter pin is the negative pole. My current connection method is to connect the positive pole in series with a 220R resistor to digital ground, and the negative pole directly to Seed’s D0
That’s a much better description. To invert that, connect the ‘+’ side of the LED+resistor +3.3, and the ‘-’ side to D0.
Thank you very much. I’ll have a try.
Did you get it working?
