Communication with an ATtiny and Arduino. For saving Pins.

Hope this is the right section for this query.
I wanted to ask something about how to send diffirent variables to a attiny controller.

Like for example if I want to control ? row of LEDS numbered trough 1 - 5 connected to a Attiny. How can I turn them on by using a number 1 - 5 which would be sended to the Attiny from the Arduino to control the LEDS individually. I would find this helpful because instead of connecting all 5 leds to the Arduino you could use just one pin to control the Attiny that would take care of the five LEDS. So the arduino would have 4 free pins!!

I would like to use this technique for my 4x4x4 LED project cube that I want to start soon!

If possible please show me some sample code, THANK YOU!!

Please see the image for better explanation.

You can use the 85's USI port and shiftOut() on the Arduino.

Send bytes to the 85 and write some code on it to read those bytes and take action.

An alternative to sending command bytes is to just send the bit pattern you wanted the 85 to write to it's IO port.


Rob

WOW! Thank you bro! Really thank you so much, I really appreciate it! :sweat_smile:

Umm... but one thing. wher's the USI on the ATTINY? is it two wires? where to I connect it to on the Arduino?

wher's the USI on the ATTINY?

Have a look at the data sheet.

MOSI pin5
MISO pin6
SCK pin7

But you don't need MISO because you are only talking one way.

is it two wires?

Yep, see above.

where to I connect it to on the Arduino?

Any two pins you like if using shiftOut(), or the SPI pins (SCK and MOSI) if you want to use the SPI hardware.

but one thing

Actually that's three things :slight_smile:


Rob

What I ought to mention as nobody has picked up on it yet, the ATtiny85 doesn't have enough I/O pins to do what you want. It only have 5 pins which means you could only have 3 LEDs if you used 2 pins for communication.
It is possible to disable the Reset pin and gain an extra I/O pin which would allow you to have 4 LEDs, however this requires either a High voltage programmer or a bootloader (The latter of which takes up 576bytes of flash).

You can do it with an ATtiny, but you have to charlieplex the LED`s.

Wouldn't a shift register be useful here? http://arduino.cc/en/Tutorial/ShiftOut

You could use a serial connection between Arduino and the Tiny: Arduino TX -> Tiny RX, Gnd->Gnd.
This will leave you with 4 pins free on the Tiny.
On the Tiny you use SoftwareSerial to receive the communication from Arduino

the ATtiny85 doesn't have enough I/O pins to do what you want.

Good point.

Wouldn't a shift register be useful here?

Another good point.

You could use a serial connection between Arduino and the Tiny:

That'll work to.

mixania, just use a shift register and save yourself a lot of pain :slight_smile:


Rob

add 8 16bit I2C GPIO expanders, and use charlieplexing
there you go, direct control for 16256 LEDs, using only two pins of your Arduino

enough for a 25 x 25 x 25 LED cube $)

Wow guys! Thank you so much. I really appreciate it!

Graynomad:
But you don't need MISO because you are only talking one way.

oh.. that right! Thanks! :open_mouth:

But I have some more questions guys... :roll_eyes:

It's alright.. I just want to understand how this "business" works. I will get a Attiny with more pins if needed. :wink: Thanks anyway! :wink:

How exactly to load it? $)

Lakes:
You can do it with an ATtiny, but you have to charlieplex the LED`s.
UziMonkey's blog: Charlieplexing on the Arduino

http://www.instructables.com/id/Creating-a-charlieplexed-LED-grid-to-run-on-ATTiny/

WOW! LOVE YOUR LINKS, THANKS! :smiley: :smiley:
really helpful.

Graynomad:
mixania, just use a shift register and save yourself a lot of pain :slight_smile:

Hmmm.. What about it? How it works? ]:smiley:

NiñoScript:
add 8 16bit I2C GPIO expanders, and use charlieplexing
there you go, direct control for 16256 LEDs, using only two pins of your Arduino

enough for a 25 x 25 x 25 LED cube

Wow! Man thats crazy! maybee some day.. :stuck_out_tongue_closed_eyes: $) 8) :astonished: