Serial communication is not difficult on an ATtiny thanks to the SoftwareSerial Library. While the ATtiny85 does not have the hardware of a "real" Arduino, it can still function in similar fashion. If you're just getting started with using an ATtiny, here are some resources you might need.
- Information on programming them from High-Low Tech. You can also look back at my previous posts.
- My nifty programming adapter. A few minutes of soldering made my life much easier.
- My USBtinyISP is discussed in THIS post. It also makes life easier.
- Previous posts on Running Servos and the NewPing Library on an ATtiny.
- THIS previous post mentioning my USB to UART converter cable
Now we are ready to go. First things first, I am using Arduino 1.0.4. The SoftwareSerial Library is included as a default library, so there is no reason to get a 3rd party library.
Step One: Wire it up. With my USB to UART cable it is as follows.
- Black: Ground
- Green: Tx (using Tx as pin 4)
- White: Rx (using Rx as pin 3)
- Red: 5v (this is optional if you have an external power supply)
Connect an LED with appropriate resistor to pin 1.
Step Two: Ensure that your ATtiny is burned to run at 8MHz. Now load THIS sketch onto the ATtiny. Note that parseInt() works with the SoftwareSerial Library.
Step Three: Open the Serial Monitor and set it to the correct Baud rate. To reset the ATtiny, bridge the reset pin to ground momentarily. When you see the connected message, enter an integer and count the flashes.
That's all there is to it. I you don't have a USB UART cable, this is easily adaptable to communication with another Arduino with a USB port. See THIS post for code. If you want to see a practical application of serial communication on an ATtiny85, check out my serial sonar controller HERE.
Hope this works for you all. As usual, if there are any questions, just let me know.
-Matthew