Arduino Development Board
Digispark is a compact and inexpensive Arduino development board, priced around 6.5 yuan, but it is very powerful and can achieve various interesting applications, see: the smallest Arduino development board Digispark, implementing the first program with Digispark.
Digispark Development Board
There are many similar small development boards, for example, Iteaduino Tiny is a micro development board based on the Attiny85 main control. This mainboard is very compact, low power consumption, and easy to use. This board is a derivative board designed based on Digispark, supports using a specific Arduino IDE, and programming with Arduino syntax, making it very easy to get started.
Processor |
Atmega85-20 |
Operating Voltage |
5V |
Digital Signal Pins |
PB0, PB1, PB2, PB5 |
Analog Signal Input Pins (ADC) |
PB2 |
Indicator Light |
D1(PB1), PWR |
Output Current |
40mA |
Flash Memory |
8 KB (2 KB for bootloader) |
SRAM |
512B |
EEPROM |
512B |
Clock Frequency |
16 MHz |
Board Size |
24.89X12.7X1.6mm |
This design of development board using ATtiny85 as the main control chip is very simple. Students interested in this can try designing one themselves, using Altium Designer to draw the circuit board.
In fact, the shake stick itself is a very good luxury Digispark development board. Just solder pins at the reserved socket position, and various developments can be carried out.
10 gold-plated boards shake stick
Applications based on Digispark
You can not only use the popular Arduino UNO R3 development board to complete some basic circuit experiments, but also Digispark can do the same.
ATtiny85 Pin Diagram
Automatic Control Street Light
Requirement: Use a photoresistor to detect light intensity, simulating an automatic control street light experiment. During the day when the light is strong, the street light is off; at night when the light is weak, the street light is on.
The schematic for the automatic control street light is shown below. One end of the photoresistor is grounded, and the other end is connected to +5V through a resistor. At night, when there is no light, its resistance is very high, about several megaohms, and almost all the voltage drops across the photoresistor, resulting in a high voltage at point PB2; when it receives strong light during the day, its resistance drops to several hundred ohms to several thousand ohms, the current increases, the voltage across the fixed resistor increases, and the voltage across the photoresistor decreases, resulting in a low voltage at point PB2, even close to 0V. Digispark samples the analog voltage at point P2, which is equivalent to detecting the light intensity, and controls whether to light the LED (street light) through pin PB1.
Automatic Control Street Light Schematic
Reference Code
int threshold =400; // Light intensity value, adjust based on actual conditions
void setup ( )
{
pinMode(PB1, OUTPUT); // Set output port
}
void loop( )
{
int n = analogRead(PB2); // Read analog port PB2
if (n>threshold ) // At night, light is dark, n value increases
digitalWrite(PB1, HIGH); // Light up the street light
else
digitalWrite(PB1, LOW); // Turn off the street light
delay(100);
}
In Arduino, there is no need to call the pinMode() function to specify the analog input port as input or output mode, which is different from digital I/O ports.
Automatic Dimming Desk Lamp
Requirement: Automatically adjust the brightness of the desk lamp based on light intensity. The desk lamp is still replaced by an LED.
Since the LED only has two states: on and off, this example uses Pulse Width Modulation (PWM) technology to control the brightness of the LED, still using the above circuit, utilizing analogWrite(pin, value) to output the PWM wave.
PWM control technology allows the microcontroller to output a pulse waveform with adjustable duty cycle, effectively obtaining the desired waveform (including shape and amplitude) by modulating the width of a series of pulses. PWM control technology is widely used in measurement, communication, power control, and conversion fields.
Reference Code
void setup()
{
pinMode(PB1,OUTPUT); // Set output port
}
void loop()
{
int n = analogRead(PB2); // Read light intensity
analogWrite(PB1, 255-n/4); // Output PWM wave based on light intensity
delay(200);
}
You can also try to modify the following several experiments based on Arduino UNO R3 to use Digispark. Note that due to pin limitations, consider using IIC interface for the OLED screen.
-
Arduino Example – Pyroelectric Sensor
-
Arduino Example – Using DHT11 to Detect Environmental Temperature and Humidity
-
Arduino Example – Ultrasonic Distance Measurement
-
Arduino Example – Lighting up OLED Screen
Introduction to ATTiny13
If you find the price of ATtiny85 too expensive, you can consider using ATtiny13. ATTiny13 is a microcontroller with 8 pins, which also supports Arduino development.
Data Capacity
-
1K Bytes(1024 Bytes) programmable Flash memory
-
64 Bytes EEPROM
-
64 Bytes on-chip SRAM
Channel Interface
-
8-pin PDIP/SOIC package: 6 programmable I/O pins
-
1 8-bit timer/counter and 2 PWM channels
-
4 10-bit ADC (one of which is Reset)
-
DC current of 20mA (maximum 40mA) for each I/O pin
-
Operating Voltage 1.8 – 5.5V (maximum 6V)
Since ATtiny13 only has 1kB of Flash available for programming, the program must be refined, and the size of the program must be strictly controlled.