Introduction: Easy ATTiny Serial Communication With Tiny AVR Programmer
ATTinies (like the ATTiny 85) are super awesome! They are super cheap, low power, and they do what most Arduino projects accomplish anyway (give a simple output or take in a simple input).
One difficulty can be quickly seeing what's going on with their internals for easy debugging. The ATTInies can't use the hardware serial built in to many larger arduinos, and so you need to use the SoftwareSerial library. This can be a bit tricky or confusing. Other people use software serial for directly programming their Tinies in the first place with all kinds of crazy hookups, and maybe capacitors, and USB to serial devices. You might even have to put special software on the arduino talking to the hardware serial, and the one just using software serial.
Some of us who have only used Dave Mellis's tinyAVR programmer get a bit confused, or are just too lazy to try that all out. It can be confusing for beginners, and I wanted the simplest way to teach my animal interaction design students how to use these great little microcontrollers.
So thanks to help from Paul O'Neil, I wanted to describe really quickly a simple method for talking with your ATTiny and the only extra necessary material is an Arduino Uno or Duemillanove (or Seeeduino that acts like one).
If you are new to programming ATTinies go check out the nice tutorial over at HLT and then come back here after you get your environment setup.
MATERIALS
++Photo of Pinouts
++Photo of
Special Extra Learning Notes
One difficulty can be quickly seeing what's going on with their internals for easy debugging. The ATTInies can't use the hardware serial built in to many larger arduinos, and so you need to use the SoftwareSerial library. This can be a bit tricky or confusing. Other people use software serial for directly programming their Tinies in the first place with all kinds of crazy hookups, and maybe capacitors, and USB to serial devices. You might even have to put special software on the arduino talking to the hardware serial, and the one just using software serial.
Some of us who have only used Dave Mellis's tinyAVR programmer get a bit confused, or are just too lazy to try that all out. It can be confusing for beginners, and I wanted the simplest way to teach my animal interaction design students how to use these great little microcontrollers.
So thanks to help from Paul O'Neil, I wanted to describe really quickly a simple method for talking with your ATTiny and the only extra necessary material is an Arduino Uno or Duemillanove (or Seeeduino that acts like one).
If you are new to programming ATTinies go check out the nice tutorial over at HLT and then come back here after you get your environment setup.
MATERIALS
- ATTINY 85
- TinyAVR Programmer (it's on sparkfun)
- 2 wires
- "Slave" Arduino Uno or Duemillanove (or Seeeduino that acts like one).
++Photo of Pinouts
++Photo of
Special Extra Learning Notes
- We'll find out that your
- We'll find out that analog input 2 is a bit tricky on the ATTiny
Step 1: Program the ATTINY With Software Serial Commands
Check out this example code where you invoke SoftwareSerial, and then use it like you normally use it in your sketches. Program your ATTiny with this:
https://github.com/quitmeyer/ATtinyBareDemos/blob/master/ATTinyAnalogInputTOSerial/ATTinyAnalogInputTOSerial.ino
(BTW Anyone know how to embed github code in an instructable? I tried gists, and gist-it)
https://github.com/quitmeyer/ATtinyBareDemos/blob/master/ATTinyAnalogInputTOSerial/ATTinyAnalogInputTOSerial.ino
(BTW Anyone know how to embed github code in an instructable? I tried gists, and gist-it)
Step 2: Attach Wires and Hook Up Full Size Arduino
Connect the pins labeled "3" and "4" on your ATTINY Programmer to pins "0" and "1" on your full sized arduino. Connect your big arduino to your USB.
Make sure to program your "slave" full sized arduino to a simple program that is not using the serial (or else you can have conflicts). I recommend programming the slave arduino with the
FILE>EXAMPLES>BASICS>BARE MINIMUM sketch.
It just looks like this
///////
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
//////
Make sure to program your "slave" full sized arduino to a simple program that is not using the serial (or else you can have conflicts). I recommend programming the slave arduino with the
FILE>EXAMPLES>BASICS>BARE MINIMUM sketch.
It just looks like this
///////
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
//////
Step 3: Open Arduino's Serial Monitor
In the Arduino Software click the button in the upper right to open the Serial Monitor. Make sure that your big arduino device was recognized under "Tools>Serial Port"
Now you should be able to see what your ATTINY is saying!
This is a great tool for debugging, or if you need to send commands to some other program like a processing sketch to visualize what your ATTiny is sensing!
Now you should be able to see what your ATTINY is saying!
This is a great tool for debugging, or if you need to send commands to some other program like a processing sketch to visualize what your ATTiny is sensing!