Go Down

Topic: Communication with an ATtiny and Arduino. For saving Pins. (Read 1 time) previous topic - next topic

mixania

Sep 09, 2012, 06:54 pm Last Edit: Sep 13, 2012, 03:58 am by mixania Reason: 1
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.
Arduino Uno R3
Mac OSX Lion

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

mixania

#2
Sep 10, 2012, 02:20 am Last Edit: Sep 10, 2012, 02:26 am by mixania Reason: 1
WOW! Thank you bro! Really thank you so much, I really appreciate it! :smiley-sweat:

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

Graynomad

Quote
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.

Quote
is it two wires?

Yep, see above.

Quote
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.

Quote
but one thing

Actually that's three things :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Tom Carpenter

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).
~Tom~


dxw00d


Erni

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

Graynomad

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

Good point.

Quote
Wouldn't a shift register be useful here?

Another good point.

Quote
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 :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

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  $)

mixania

#10
Sep 13, 2012, 04:01 am Last Edit: Sep 13, 2012, 04:16 am by mixania Reason: 1
Wow guys! Thank you so much. I really appreciate it!


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


oh.. that right! Thanks! :smiley-surprise:

But I have some more questions guys... :smiley-roll-blue:


It only have 5 pins which means you could only have 3 LEDs if you used 2 pins for communication.


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


however this requires either a High voltage programmer or a bootloader (The latter of which takes up 576bytes of flash).


How exactly to load it?  $)


You can do it with an ATtiny, but you have to charlieplex the LED`s.
http://uzimonkey.blogspot.co.uk/2009/01/charlieplexing-on-arduino.html

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



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


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


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


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..  :smiley-yell: $)  8)  :smiley-eek:
Arduino Uno R3
Mac OSX Lion

Go Up