Skip to content

Instantly share code, notes, and snippets.

@dbdness
Last active June 26, 2024 20:38
Show Gist options
  • Save dbdness/072b032ecbab80578730345dbe68fb5b to your computer and use it in GitHub Desktop.
Save dbdness/072b032ecbab80578730345dbe68fb5b to your computer and use it in GitHub Desktop.
DigiSpark Kickstarter ATTINY85 Setup on macOS + Hello World

Digispark ATTINY85 Initial Setup on macOS + Hello World

Originally written in January 2021.

Originally written for macOS Big Sur 11.1

Step 1: Acquire a DigiSpark ATTINY85 Board

Board used for this guide is the Kickstarter version.

Step 2: Download the Arduino IDE

Version at the time of writing is 1.8.13

a) Downloading the .app: https://www.arduino.cc/en/software b) Using Homebrew

$ brew install --cask arduino

Step 3: Setup Digispark Development Environment through Arduino IDE

  1. Update board source In Arduino IDE, go to File -> Preferences and dump the following into the Additional Boards Manager URLs box:

http://digistump.com/package_digistump_index.json

  1. Install the Digistump AVR Boards Still in Arduino IDE, go to Tools -> Board -> Boards Manager. From the Type dropdown, select Contributed. Select the Digistump AVR Boards package and click install.

  2. Set the Digistump AVR Boards as the default board Still in Arduino IDE, go to Tools -> Board -> Digitump AVR Boards -> Digispark (Default - 16.5mhz).

Step 4: Verify Environment with Sample 'Hello World' Script

  1. Paste the following into the sketch present in Arduino IDE:
#include "DigiKeyboard.h"
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  DigiKeyboard.delay(2000);
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.sendKeyStroke(KEY_SPACE, MOD_GUI_LEFT);
  DigiKeyboard.delay(600);
  DigiKeyboard.print("Hello, World!");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  for(;;){ /*empty*/ }
}

When this script executes through the board, it will simply open a Spotlight Search, enter "Hello, World!" and press Enter.

  1. Verify the script before you upload it, by clicking "Verify" in the top-left corner (alternately, Sketch -> Verify/compile).

If all is well, you should see the following output in the console at the bottom:

Sketch uses 2700 bytes (44%) of program storage space. Maximum is 6012 bytes.
Global variables use 95 bytes of dynamic memory.

NB: However, if you experience the following error:

fork/exec /Users/XXXXX/Library/Arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/bin/avr-g++: bad CPU type in executable
Error compiling for board Digispark (Default - 16.5mhz).

The solution is to substitute (link) the built-in, outdated AVR tools that Digistump config looks for, with the new, updated one included in the Arduino IDE (Thanks to user Anjin from the Digistump boards). It is done in the following way:

For Arduino IDE 1.x:

$ cd ~/Library/Arduino15/packages/arduino/tools/avr-gcc
$ mv 4.8.1-arduino5 orig.4.8.1
$ ln -s /Applications/Arduino.app/Contents/Java/hardware/tools/avr 4.8.1-arduino5

For Arduino IDE 2.x (thanks to @jorgezazo and vgenov-py):

$ cd ~/Library/Arduino15/packages/arduino/tools/avr-gcc 
$ mv 4.8.1-arduino5/ orig.4.8.1 
$ ln -s ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7 4.8.1-arduino5

Step 5: Upload and Execute 'Hello World' Script

Once the script can be verified with no issues (as per step 4), prepare the Digispark ATTINY85 board.

  1. From the Arduino IDE, click "Upload" in the top left, and wait for the prompt:
Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)
  1. Plug in the board and wait.

  2. The following should be displayed in the Arduino console, and the script should self-execute on the machine:

> Device is found!
connecting: 16% complete
connecting: 22% complete
connecting: 28% complete
connecting: 33% complete
> Device has firmware version 1.6
> Available space for user applications: 6012 bytes
> Suggested sleep time between sending pages: 8ms
> Whole page count: 94  page size: 64
> Erase function sleep duration: 752ms
parsing: 50% complete
> Erasing the memory ...
erasing: 55% complete
erasing: 60% complete
erasing: 65% complete
> Starting to upload ...
writing: 70% complete
writing: 75% complete
writing: 80% complete
> Starting the user app ...
running: 100% complete
>> Micronucleus done. Thank you!
@DevelopMan
Copy link

Does anybody face this issue?

Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)
> Please plug in the device ... 
> Press CTRL+C to terminate the program.
> Device search timed out

It worked before I started playing with libraries. I installed AltSoftSerial, SoftSerialTX, and a new board ATTinyCore. At some point, it stopped working. I tried to reinstall Arduino IDE and I removed all installed libraries, but it still doesn't work.

@dbdness
Copy link
Author

dbdness commented May 8, 2024

Guys, if you're using ATTINY85 General Micro USB(USB male connector on the board) and Type C adapter, you can try to plug in thru a usb type A male to female cable. When I plug into the adapter directly without the cable, it fails 100%. But, when I use the cable, it succeeds 100%.

Agreed, I did not encounter any connection issues with a regular USB 2.0 extender (male to female).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment