Trouble Multiplexing

No, that didn’t help at all.
Also because if you take out read-4067 from the node, the flickering is still there,
so it must be something related to write.
thanks for looking into this, but I wonder if there is somebody out there who has an example of how I can implement this, or maybe this IC is the wrong one for the job.

It would be a lot easier if your “remote” IC could handle the PWM on its own instead of relying on the Arduino to try to switch digital pins over I2C fast enough. Is your current IC able to do this if you send it analog values? A board designed for controlling servos might work (not sure since servo control is not straight PWM).

From Data sheet:
" 74HCT4067 is a single-pole 16-throw analog switch (SP16T) suitable for
use in analog or digital 16:1 multiplexer/demultiplexer applications. The switch features
four digital select inputs (S0, S1, S2 and S3), sixteen independent inputs/outputs (Yn), a
common input/output (Z) and a digital enable input (E). When E is HIGH, the switches are
turned off. Inputs include clamp diodes. This enables the use of current limiting resistors
to interface inputs to voltages in excess of VCC.
 Analog multiplexing and demultiplexing
 Digital multiplexing and demultiplexing
 Signal gating
I’m not really an expert at all, trying to make sense of things as they come my way, but I read more and more that controlling LED with this 74HC4067 might not be such a good Idea…
Everybody recommends 74HC595, so I will give it a try next, first I have to figure out the connections and the library in XOD.
I did modify the write-4067 node by replacing the pwm-write with the pwm-load node, and the LED respond much better, still with visible flickering but much more stable in brightness. Also I have coupled the LEDs with transistors and that also improved things

How are you powering all of this? Is it possible you are drawing too much power for your supply? Is VCC provided within range for ICs? Once you set IC to specific PWM value, it should control the LED with no input from Arduino. If you are getting flickering, either there is something wrong with IC, or Arduino is telling it to turn off & back on again rather than just leaving it on. If I’m reading your patch correctly, you are trying to change value for LED control pin very frequently. You just want to set the pwm value once, then leave it until you want a different brightness. The pwm value (between 0 and 1) will control brightness without constantly changing the value for the LED pin.

I don’t think power is an issue, problems are evident even with just one led, even if connected through a transistor to raw 5V input.
but I think you nailed the problem on the IC, it doesn’t have the ability to store a state until the next update as far as I can tell, it’s just switching between inputs like a madman and it shows on the LEDS flickering. it seems to me that the 74HC595 can do the job right, I am hooking it up now, but I have to figure out how to talk to it, wish me luck…

p.s. by the way, HC4067 does a great job at reading analog inputs…

Remembering a previous topic, there you need to use a ic with latch(HCT4351) to retain the previous states, with a 4067 it will be enough.

So I got it working, worked out a way to dim the LEDs


I read the 595 is capable of pwm, but I couldn’t figure out how to do it with the library in XOD (thanks so much to you guys for providing it).
so I used a square wave to control the duty cycle, only problem is it doesn’t turn the led off, but I can find a way to make it work.
I wonder if there is a more elegant/simple way to do this, but for now that’s all I need to carry on my project.
thanks to all

New problem…
so if I copy and paste the above sketch 32 times, for each led i wish to control, the pro micro runs out of program space.
I am sure I am doing something stupid and there is a neat way to cycle through the inputs and outputs applying the same function to them.
so I explain what I am trying to achieve:
16 pads, each has one led normally on and one normally off.
when I press the pad, the on led turns off and the off led fades on to a brightness that is dependent on the pressure applied to the pad.
This can be done pretty easily with the Arduino IDE with a few lines of code, I imagine XOD can do the same, I just don’t know how to do it, yet…
I could also do it physically with transistors and logic gates, but I plan to program patterns for when buttons are pressed, that’s why I am trying to do it in the IDE.
Any ideas would be greatly appreciated

I think if you want to dim 16 LEDs and perform other functions, you need to get PWM working so the hardware can handle dimming instead of trying to emulate dimming in software with the square-wave node. That will free up a lot of memory and processing power (and make your program easier to write). Their aren’t enough timers available to use 16 square-wave nodes and still have some free for XOD to use.

There are two functions hc-595-setpin and hc595-setpin-noupd use hc595-setpin-noudp and then hc-595-upd-all.

Then load all values then update.

ps: use nth-input to load

You are very right.


this works and frees up a lot of memory, also the leds respond much better.
Still there is much more I have to implement in this patch, and I don’t know if it will fit in the end…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.