Digispark Rev.3 ATTiny85 - EN
Digispark Rev.3 ATTiny85 - EN
Thank you for purchasing our AZ-Delivery Digispark Rev.3 with ATTiny85. On
the following pages, you will be introduced to how to use and set-up this
handy device.
Have fun!
Table of Contents
Introduction....................................................................................................3
Specifications................................................................................................4
Features of ATTiny85....................................................................................5
The pinout.....................................................................................................6
The schematic...............................................................................................8
How to set-up Arduino IDE..........................................................................10
Additional setup.......................................................................................14
Windows drivers......................................................................................16
Linux drivers............................................................................................17
Sketch examples.....................................................................................18
ADC and PWM sketch.............................................................................19
-2-
Introduction
The Digispark has an on-board USB port and can be plugged into a PC
USB port without the necessity of an additional cable. It can be powered
directly from the USB port. The second way that the module can be
powered on is via three additional power supply pins.
The Digispark has six general purpose input/output (GPIO) pins which have
multiple functions, for example, USB functions, ADC functions, I2C interface
pins, SPI interface pins, etc. This can be seen on a pinout diagram image
(later in the text).
-3-
Specifications
The Digispark has two on-board LEDs. One is for power indication, and the
other is connected to the pin 1 (PB1).
-4-
Features of ATTiny85
-5-
The pinout
The Digispark has nine pins. The pinout is shown on the following image:
The Digispark has total of 9 pins and USB connector. There are 6 GPIO
pins, 3 additional pins for external power supply and the USB (OTG - On
The Go type) connector. Two pins (2 and 3) are connected to the USB port
data pins. To utilise pins (2, 3) as GPIO pins, USB must be disabled.
The pins with a (PB) designations on the pinout image are the actual pin
names that are used when addressing the pins from the code in the Arduino
IDE.
-6-
To use the RESET pin to reset the microcontroller, the pin has to be driven
LOW. To do this safely, use the push down button with pull down resistor
connected between the RESET pin and GND. By default the RESET pin I/O
function is disabled by the micronucleus bootloader code and as such can
not be used as the GPIO pin, only as RESET pin. There are other methods
to disable reset function of the pin and make it usable as I/O pin but that is
not in the scope of this eBook.
-7-
The schematic
The schematic diagram shows the simplicity of the Digispark circuit. The
circuit consists of an ATTiny85 chip, voltage regulator, diodes, few resistors,
capacitors and LEDs.
The Digispark has 3 additional pins (JP2) for external power supply, the VIN
voltage input pin and it can be supplied with voltages from 6V to 12V. The
voltages are regulated by an on-board 5V voltage regulator. The voltage
regulator current limit is 500mA.
-8-
The 5V pin is a voltage output pin and can supply other peripheral devices
connected to Digispark. The overall current consumption should not exceed
the limit (500mA) of the voltage regulator, otherwise damage may occur.
-9-
How to set-up Arduino IDE
If the Arduino IDE is not installed, follow the link and download the
installation file for the operating system of choice.
For Windows users, double click on the downloaded .exe file and follow
the instructions in the installation window.
- 10 -
For Linux users, download a file with the extension .tar.xz, which has to
be extracted. When it is extracted, go to the extracted directory and open
the terminal in that directory. Two .sh scripts have to be executed, the first
called arduino-linux-setup.sh and the second called install.sh.
To run the first script in the terminal, open the terminal in the extracted
directory and run the following command:
sh arduino-linux-setup.sh user_name
user_name - is the name of a superuser in Linux operating system. A
password for the superuser has to be entered when the command is
started. Wait for a few minutes for the script to complete everything.
The second script, called install.sh, has to be used after the installation
of the first script. Run the following command in the terminal (extracted
directory): sh install.sh
After the installation of these scripts, go to the All Apps, where the
Arduino IDE is installed.
- 11 -
Almost all operating systems come with a text editor preinstalled (for
example, Windows comes with Notepad, Linux Ubuntu comes with
Gedit, Linux Raspbian comes with Leafpad, etc.). All of these text
editors are perfectly fine for the purpose of the eBook.
- 12 -
If the Arduino IDE is used on Windows, port names are as follows:
- 13 -
Additional setup
For the Arduino IDE to be able to recognize the Digispark, several settings
has to be set. When the installation is finished, open the Preferences
window, with the following menu command: File > Preferences
The following link text has to be copied in the Additional Boards Manager
URLs text box: http://digistump.com/package_digistump_index.json
as on the following image:
Click OK to finish.
- 14 -
The Digispark board support has to be installed in Arduino IDE. To do so go
to:
Tools > Board > Boards Manager...
when new window opens, under the Type (drop-down menu), select the
option Contributed as on the following image:
Next, in the search box type digistump and search for Digistump AVR
Boards as on the following image:
- 15 -
Windows drivers
To use the Digispark with the Arduino IDE on Windows, the USB driver for
the Digispark has to be installed. The driver can be downloaded from the
following link. Extract the downloaded file and open the folder where the file
is extracted. Double click the installation file called DPinst64.exe. For the
32bit version of Windows, execute the file called DPinst.exe.
- 16 -
Linux drivers
and
sudo apt-get install libusb-0.1-4
After the installation of these apps, the Arduino IDE is able to detect the
USB port on which the Digispark module is connected. If it still can not
detect the Digispark module, restart the system after installation of these
apps.
- 17 -
Sketch examples
Blink sketch
void setup() {
pinMode(1, OUTPUT);
}
void loop() {
digitalWrite(1, HIGH);
delay(1000);
digitalWrite(1, LOW);
delay(1000);
}
In the setup() function mode of the digital pin 1 is set to OUTPUT. The
on-board LED is connected on the pin 1. In the loop() function the delay
time is set and the on-board LED turns ON and OFF in intervals of one
second.
- 18 -
ADC and PWM sketch
- 19 -
The sketch starts with creating two macros that represent the digital I/O
pins.
The first macro defines the pin to witch the on-board LED is connected and
the PWM signal is outputted. The second macro represents the analog pin.
The resistance of the potentiometer that is read through this pin changes
the PWM value.
Next, in the setup() function the mode of digital pin connected to an on-
board LED is set to OUTPUT and initialized.
After that, the function called analogRead() is created. The function has
one argument and retruns an integer value. The argument is an integer
value and represents the analog input pin from which the analog voltage is
read. The return value, also an integer value, is the digital representation of
the read analog voltage. This value is in the range from 0 to 1023 (10bit
resolution of ADC converter of the ATTiny85 chip). The PWM value is an
8bit value, and integer value in the range from 0 to 255. To use the value
returned by analogRead() function to set the PWM value, the
analogRead() value has to be divided by 4, an integer division. This is
done with the following line of code:
value = value / 4;
At the end of the sketch, the delay of 100ms is set. This is the time interval
between two analogRead() measurements.
- 20 -
Now it is the time to learn and make your own projects. You can do that with
the help of many example scripts and other tutorials, which can be found on
the internet.
https://az-delivery.de
Have Fun!
Impressum
https://az-delivery.de/pages/about-us
- 21 -