Difference between revisions of "Sensor-Module LED Matrix"
From Microduino Wiki
(9 intermediate revisions by 3 users not shown) | |||
Line 12: | Line 12: | ||
*With uniform Microduino interface standard and rich peripheral modules, it can flexibly connect with other modules and sensor. | *With uniform Microduino interface standard and rich peripheral modules, it can flexibly connect with other modules and sensor. | ||
*2.54mm (0.1 inch) pin pitch, compatible with bread boards and pegboards. | *2.54mm (0.1 inch) pin pitch, compatible with bread boards and pegboards. | ||
− | *Controlled by Analog port on the back with A0, A1, A2, A3, A6 and A7 for option. | + | *Controlled by Analog port on the back with A0, A1, A2, A3, A6 and A7 for option. '''A0 is the default pin.''' |
[[File:Pinout.jpg|800px|thumb|center|Microduino-RTC-Pinout1]] | [[File:Pinout.jpg|800px|thumb|center|Microduino-RTC-Pinout1]] | ||
Line 21: | Line 21: | ||
**Up to 800Kbps data transmission rate. | **Up to 800Kbps data transmission rate. | ||
− | + | ||
− | |||
− | |||
===Main componet=== | ===Main componet=== | ||
*WS2812 wiki page: http://wiki.hacdc.org/index.php/WS2811_Digital_RGB_LED#Individual_LEDs | *WS2812 wiki page: http://wiki.hacdc.org/index.php/WS2811_Digital_RGB_LED#Individual_LEDs | ||
Line 30: | Line 28: | ||
===Arduino Library and Support Package=== | ===Arduino Library and Support Package=== | ||
− | *Adafruit_NeoPixel:https://github.com/adafruit/Adafruit_NeoPixel | + | *Adafruit_NeoPixel: https://github.com/adafruit/Adafruit_NeoPixel |
+ | |||
+ | *Further reading on the Neopixel library: https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library | ||
==Project== | ==Project== | ||
Line 38: | Line 38: | ||
Open IDE, click File→ Examples →Find LED_WS2812 | Open IDE, click File→ Examples →Find LED_WS2812 | ||
[[file:ANlib.jpg|600px|center]] | [[file:ANlib.jpg|600px|center]] | ||
+ | |||
+ | *Change '''#define PIN 6''' to '''#define PIN A0''' as the LED Matrix uses '''A0''' as its default pin. | ||
+ | *Change Adafruit_NeoPixel strip = Adafruit_NeoPixel('''60''', PIN, NEO_GRB + NEO_KHZ800); From 60 to 6. (Since, there is only 6 LEDs in the strip.) | ||
<source lang="cpp"> | <source lang="cpp"> |
Latest revision as of 20:39, 22 February 2017
Language: | English • 中文 |
---|
Microduino-LED Matrix module integrates six WS2812 lights and each light has an IC control chip inside. Six lights adopt single bus control, so you can control each light with one I/O port, which can offer optical source for full-color modules. ContentsFeatures
Specification
Main componet
DevelopmentArduino Library and Support Package
ProjectVoice Control LightDebugging ProgramAdopt Adafruit_NeoPixel program example from Microduino IDE. Open IDE, click File→ Examples →Find LED_WS2812
#include <Adafruit_NeoPixel.h>
#define PIN 6 //Define control pin
// Parameter 1=Colored LED number in "strip".
// Para.2=Pin number
// Para.3=Colored LED type. Optional(Select one from the first two or the last two)
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
strip.begin();
strip.show(); //Initialize all light strips are out.
}
void loop()
{
// Method to lighten all lights.
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
rainbow(20);
rainbowCycle(20);
}
//"c"(color); All lights get lightened in order and it takes a few seconds for the next light to get lightened before the last one.
void colorWipe(uint32_t c, uint8_t wait)
{
for(uint16_t i = 0; i < strip.numPixels(); i++) //Get lightened in order.
{
strip.setPixelColor(i, c); //The function is used for lightening the "i" light strip with the "c" color.
strip.show(); //The function will display the control info. written by the function "setPixelColor".
delay(wait);
}
}
void rainbow(uint8_t wait) //Rainbow display
{
uint16_t i, j;
for(j = 0; j < 256; j++) //225 kinds of color change gradually
{
for(i = 0; i < strip.numPixels(); i++) //Light up the lights in sequence and wait for a few millisecond
{
strip.setPixelColor(i, Wheel((i + j) & 255));
}
strip.show();
delay(wait);
}
}
// Different from the function above, it adds rainbow loop.
void rainbowCycle(uint8_t wait)
{
uint16_t i, j;
for(j = 0; j < 256 * 5; j++) //The rainbow circulates for five times.
{
for(i = 0; i < strip.numPixels(); i++)
{
//Mathematical transformation added for the loop.
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// Enter a number within 0-225 and get the only corresponding color.
// The color will change from red, green to blue and then red gradually and repeatedly.
uint32_t Wheel(byte WheelPos)
{
if(WheelPos < 85)
{
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
else if(WheelPos < 170)
{
//Since the WheelPos * 3 will surpass 255 under 85-170, it needs reduce 85 firstly.
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
else
{
// Since the WheelPos * 3 will surpass 255 under over 170, it needs reduce 170 firstly.
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} PurchasePictures |