Pages: [1]   Go Down
Author Topic: Communication with an ATtiny and Arduino. For saving Pins.  (Read 1241 times)
0 Members and 1 Guest are viewing this topic.
New York, NY
Offline Offline
Full Member
***
Karma: 2
Posts: 142
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* Explain.jpg (313.33 KB, 1600x1200 - viewed 80 times.)
« Last Edit: September 12, 2012, 08:58:24 pm by mixania » Logged

Arduino Uno R3
Teensy 3.0
Mac OSX Yosemite

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

New York, NY
Offline Offline
Full Member
***
Karma: 2
Posts: 142
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: September 09, 2012, 07:26:19 pm by mixania » Logged

Arduino Uno R3
Teensy 3.0
Mac OSX Yosemite

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

~Tom~

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Denmark
Offline Offline
Edison Member
*
Karma: 37
Posts: 1096
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Viña del Mar, Chile
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino Noob
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-money
Logged

New York, NY
Offline Offline
Full Member
***
Karma: 2
Posts: 142
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-wink Thanks anyway!  smiley-wink

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?  smiley-money


WOW! LOVE YOUR LINKS, THANKS!  smiley-grin smiley-grin
really helpful.

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

Hmmm.. What about it? How it works?  smiley-twist

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 smiley-money  smiley-cool  smiley-eek
« Last Edit: September 12, 2012, 09:16:08 pm by mixania » Logged

Arduino Uno R3
Teensy 3.0
Mac OSX Yosemite

Pages: [1]   Go Up
Jump to: