Home Digispark Digispark RGB led example

Digispark RGB led example

by shedboy71

In this example we will connect an RGB led to a Digispark, a quick recap of the basic Digispark we ware using in this example


XGHF-GY Digispark Kickstarter Miniature Development Board TINY85 – Blue – $4.65

The Digispark is an Attiny85 based microcontroller development board similar to the Arduino line only cheaper smaller and a bit less powerful. With a whole host of shields to extend its functionality and the ability to use the familiar Arduino IDE the Digispark is a great way to jump into electronics or perfect for when an Arduino is too big or too much.

The Digispark is shipped fully assembled except for the two included and easy to solder headers.

Here are the specs: Support for the Arduino IDE 1.0+ (OSX/Win/Linux) Power via USB or External Source – 5v or 7-35v (12v or less recommended automatic selection)
On-board 500ma 5V Regulator
Built-in USB
6 I/O Pins (2 are used for USB only if your program actively communicates over USB otherwise you can use all 6 even if you are programming via USB)
8k Flash Memory (about 6k after bootloader)
I2C and SPI
PWM on 3 pins (more possible with Software PWM)
ADC on 4 pins
Power LED and Test/Status LED

Schematics

Here are some schematics and a breadboard layout

Digispark and RGB LED schematic

Digispark and RGB LED schematic

 

Here is the breadboard layout

Digispark and RGB LED breadboard

Digispark and RGB LED breadboard

 

Code

[codesyntax lang=”cpp”]

#define  redpin            1 
#define  greenpin            2
#define  bluepin            3

void setup() 
{ 
  // initialize the digital pin as an output.
  pinMode(redpin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  // Set high for common anode type
  digitalWrite(redpin, HIGH);  
  digitalWrite(greenpin, HIGH);
  digitalWrite(bluepin, HIGH);
}


void loop() 
{
  digitalWrite(redpin, LOW);  //red on
  delay(500);
  digitalWrite(redpin, HIGH); //red off
  digitalWrite(greenpin, LOW); //green on 
  delay(500);
  digitalWrite(greenpin, HIGH); //green off
  digitalWrite(bluepin, LOW);  //blue on
  delay(500);
  digitalWrite(bluepin, HIGH); //blue off
}

[/codesyntax]

 

Links
XGHF-GY Digispark Kickstarter Miniature Development Board TINY85 – Blue

USB Interface Digispark Kickstarter ATTINY85 Development Board – Black

Share

You may also like