Huber Girón Nieto
Electronic and Mechatronic Engineer
Contact
e-mail: huber.giron.nieto@iberopuebla.mx
phone: +52 (222) 372 3000 ext.12917
FABLAB Puebla Researcher
WEEK ASSIGNMENT:
Output devices
Add an output device to a micro-controller board you've designed and program it to do something
For this week activity we need to add a output to a micro-controller board.
We use some digital serial LED's : WS2811
Device connections
We use the attiny44A micro-controller Board made in activity six, based in Fab Academy Hello-World board:
Color Test
Using the Fast_Led Library you can change the color of each single LED using a RGB color code or using the precharged color names:
Code:
#include "FastLED.h"
#define NUM_LEDS 22
#define DATA_PIN 0
CRGB leds[NUM_LEDS];
int x=20;
void setup() {
pinMode(DATA_PIN, OUTPUT);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
leds[0] = CRGB::Black;
leds[1] = CRGB::Red;
leds[2] = CRGB::Blue;
leds[3] = CRGB::Green;
leds[4] = CRGB::Purple;
leds[5] = CRGB::Yellow;
leds[6] = CRGB::Cyan;
leds[7] = CRGB::Coral;
leds[8] = CRGB::DarkBlue;
leds[9] = CRGB::Orange;
leds[10] = CRGB::Pink;
leds[11] = CRGB::Gold;
leds[12] = CRGB::FloralWhite;
leds[13] = CRGB::Sienna;
leds[14] = CRGB::Maroon;
leds[15] = CRGB::MediumOrchid;
leds[16].r = 0;
leds[16].g = 0;
leds[16].b = 255;
leds[17].r = 0;
leds[17].g = 255;
leds[17].b = 0;
leds[18].r = 255;
leds[18].g = 0;
leds[18].b = 0;
leds[19].r = 255;
leds[19].g = 255;
leds[19].b = 0;
leds[20].r = 255;
leds[20].g = 0;
leds[20].b = 255;
leds[21].r = 0;
leds[21].g = 255;
leds[21].b = 255;
FastLED.show();
}
Change color Test
Code:
#include "FastLED.h"
#define NUM_LEDS 19
#define DATA_PIN 0
CRGB leds[NUM_LEDS];
void setup() {
pinMode(DATA_PIN, OUTPUT);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Blue;}
FastLED.show();
delay(500);
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Green;}
FastLED.show();
delay(500);
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Purple;}
FastLED.show();
delay(500);
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Red;}
FastLED.show();
delay(500);
}
Change serial color Test
Code:
#include "FastLED.h"
#define NUM_LEDS 15
#define DATA_PIN 0
CRGB leds[NUM_LEDS];
int x=80;
void setup() {
pinMode(DATA_PIN, OUTPUT);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Red;
FastLED.show();
delay(x);
}
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Blue;
FastLED.show();
delay(x);
}
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Green;
FastLED.show();
delay(x);
}
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Purple;
FastLED.show();
delay(x);
}
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Yellow;
FastLED.show();
delay(x);
}
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::White;
FastLED.show();
delay(x);
}
}