I am using my own PCB with a Amega32u4, I would like to add a 7 segment display in place of my current 4x neo pixel that uses a single pin (d4) and cant find a display to work in the same way. Looks like my only option is to use a shift register. I have every last pin used up and already have PCB made up so trying not to swap a bunch of pins around and make major changes as my code and PCB design works perfect. The problem is I have a MCP2515 that currently uses SCLK, MOSI, MISO and INT1(d2). How would I go about hooking this up on the Amega32u4 side and what other pins could I use?
If you are already using I2C you can add more devices to the same bus, An mcp23017 port expander could be used to drive the display. If you have used the I2C pins for something else then too bad. Adding an extra SPI device needs one pin per device group (CE / chip enable) so you could add a single shift register or a chain of shift registers all using the same (user definable) CE pin. The SPI pins (miso,mosi and clk) can be shared if these have not already been used for non-SPI devices. But this should be no problem since you are already using an mcp2515.
As 6v6gt has explained, SPI and I2C are interfaces that can take multiple slaves on the same pins.
I2C devices need a unique address, in theory up to 127 devices on the same two pins.
SPI need an additional select pin per device.
Leo..
Thanks for all the info, its been awhile since I work with all this and forgot a bit. I think I could move a couple things around to free up I2C pins, but INT for the MCP2515 is on the SDA and cant seem to find where that is defined in my code. Or if Im understanding for SPI miso,mosi and clk would be shared and use my only free pin (d4) as select pin. Any user defined pin will work correct?
It looks like you understand SPI.
You've said in the OP that INT1 uses D2 so that may well be "hidden" in an attachInterrupt( ) statement somewhere in setup().
But later you've mentioned SDA as also an int ?
EDIT
Aah ! SDA is D2 on an ATmega32u4
Yes, you can use pin D4 as the select pin for a new SPI device on your bus.
I suppose you know that analogue pins are just digital pins with the added functionality of analogue-in. digitalWrite(A2, HIGH); is perfectly valid.
Leo..
When you want to stay with the Neopixel protocol, take a look at the WS2811 or UCS2912.
For SPI you need one extra pin for the CS. Take a look at MAX7221.
Yes I do know, but thank you.
Staying with the Neopixel would make it simple, I could run 3x WS2811 for the 7 segment display, Im guessing the R,G,B does not apply. The UCS2912 does no seem to be to common, trying to stick with in stock components of the pcb manufacture I been using. Thanks
That is a good solution. In the code, you can set the brightness for each output. Just think in "first channel", "second channel" and "third channel".
Is there a name for "Neopixels without Neopixels" or "headless Neopixels" ?
Or you can use real Neopixels:
Using one Neopixel per segment is possible with a diffuser: https://hackaday.io/project/185748-7-segment-neopixel-display-module
Two Neopixels per segment is better: https://hackaday.io/project/183260-rgb-7-segment-display-using-neo-pixel-led
To make the pulse train for the Neopixels, interrupts are temporarily turned off. That can be nasty for some projects.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.