Hello everyone. I made a similar topic a couple of weeks ago but the project has advanced a lot. Nevertheless I have stumbled into a wall and can't seem to work this out. In case you haven't read my last topic, I decided to make a charlieplexed rgb led cube using bit angle modulation to achieve the dimming effect and blend colours. I actually prepared the code in advance and I thought that as soon as I was done with soldering, the whole thing would be ready. Oh how wrong I was. Here I am trying to figure out what the hell is wrong with this cube. Da Cube is supposed to get column data from an array, light the corresponding led column and then repeat that until all 9 column have been updated. Only 1 should be on at a time. This is where the first problem kicks in. The leds of the last column are way too bright. I slowed the interrupt routine down and apparently the last column doesn't turn off. Secondly while the leds that I want to turn on do just that, some unrelated leds also turn on. The wiring of the cube has no problems and the circuit I made in a perfboard doesn't seem to be of fault since I made a very simple sketch to check all the leds of the cube and there don't seem to be problems. I am almost sure it's the code and I would appreciate any help.
The cube is basically a simple charlieplexed matrix bent into an S shape. The last column isn't used.
The schematics and code are attached.
You can't mix LED colours in a Charlieplexed array if the forward voltages differ significantly
(can't mix red and blue for instance), since two red LEDs can conduct at the voltage of one
blue, so extra red LEDs start coming on faintly whenever the blue ones are on.
This may be part of the issue.
Why did you not use code tags for your code?
Your code would benefit greatly from refactoring all the similar cases together into a function with
suitable parameters - whenever you see lots of repetition in the source it tends to lead to error and confusion.
The code was too long to post it with the code tags. Btw with the way I have the leds wired, each color acts as a different led. I think the different voltage drops only make a difference when connected like the wikipedia example, I just don't get how a led can light without setting its cathode as LOW. Plus, with the tests I made using a very simple test sketch it seems that lighting the columns work as intended and so I think the problem lies in the code. Oh, I also figured the first problem. The last column stays on because it doesn't turn off until the next interrupt is called. I may have to get rid of the for statement for the columns and manage each column with interrupts. Now only the problem of the mysterious lit leds is left. Oh btw, these leds are usually on different columns so maybe I'm doing something wrog with the port manipulation.
Ps. I used switch because it seems to speed things up. I had to increase the interrupt counter in order for the program to work without the different cases. I will probably change this after I redisign the code but first, I want to figure out why it doesn't work as is.