So, you’ve created a project on an Arduino and want to deploy it in to the world. The problem is that an Arduino is a big and relatively expensive device that has far more things than necessary for your project.
What you really need is just the microcontroller to run your code and control the pins. All you need to do is buy an ATtiny45, ATtiny85 or similar Atmel chip, and then upload your program to it.
The Arduino makes putting your code and powering your Atmel chip very easy. Getting your code on to the stand-alone Atmel chip is a little more tricky; there are ways to program the chip with an Arduino, but they aren’t as easy as using a USBasp AVR programmer. The one I used is this one found on Ali Express.
If you are on Windows, you will need to install the drivers for the programmer. A lot of sites will say you need to disable driver signing and do a whole bunch of steps, but the drivers found here will install on Windows 10 (they are signed) when installed using the installer (but not when you try to install the drivers yourself). Once the drivers are installed, plug in the programmer and confirm your the drivers are working in device manager:
Next, you need to install the ATtiny board in to the Arduino IDE. To do this, follow these steps:
- Go to File > Preferences.
- Click on the button to edit the “Additional Board Manager URLs”.
- Add “https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json” on a new line.
- Click “OK” to close the URL editor, and “OK” again to close preferences.
- Then go to Tools > Board Managers
- Search for “ATtiny”.
- Install the attiny boards that appear (you should only have 1 result).
Next we need to set the board to be the ATtiny and the programmer to “USBasp”, use the following screenshot for reference:
We are now all set from the software end, we need to then wire up the hardware. The following pins will need to be connected:
- The MOSI from the programmer to the MOSI of the ATtiny (Pin 5)
- The MISO from the programmer to the MISO of the ATtiny (Pin 6)
- The SCK (Clock) from the programmer to the SCK of the ATtiny (Pin 7)
- The RESET from the programmer to the RESET of the ATtiny (Pin 1)
- The Vcc from the progammer to the Vcc of the ATtiny (Pin 8)
- Ground from the programmer to the ground of the ATtiny (Pin 4)
Setting these pins up can be done in a couple of ways, I decided to make a dedicated board for this with a socket, so I can program chips quickly in the future. If you do this, I recommend running some tests on a breadboard first and making sure you have all your pins properly connected before soldering it together. Here is my programmer.
Now, all that needs to be done is plug the USBasp in to the USB port of a computer and hit play, here is what the console will look like when it is all working:
Now, you can use the newly programmed ATtiny chip in a project, without have to log around the entire Arduino with it.