So, let me just share this awesome project of mine;
Where I work applications for internal use are created. The application are deployed trough a process over all assets in the environment. For the DEV team a exciting process, will it fail or succeed? As a notification to the team I’ve created a notification lamp which signals the current deployment state!
The arguments which are send to the Core is a comma separated value like “0,Hello”. Before the comma 0, 1 or 2 are used to give the LEDs a color. Behind the comma a version number is placed of the current deployment.
It all begins with this fine IKEA FRYEBO light. (not for sale in the Netherlands anymore sadly)
Change the white LEDs for addressable WS2812B LEDs;
Create a board containing the old school first edition white Core;
Underneath the Core a 74AHCT125 is placed to drive the WS2812B LEDs. The Core’s data channels are 3.3v, the LEDs need a 5v data channel. On the board there are data pins to drive a 8x8 LED Matrix. The board for the Matrix is hanging lose from the board where the Core sits on.
Lets put it all together! As you see, I have created a square hole to fit the 8x8 LED Matrix in.
Now leds see it work! (don’t mind the text)
http://gph.is/1MeDO9J
// This #include statement was automatically added by the Particle IDE.
#include "LedControl-MAX7219-MAX7221/LedControl-MAX7219-MAX7221.h"
// This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"
//NEOPixel control
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 4
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
//LED matrix control
bool matrixRun = true;
LedControl *led;
int phase = 0;
String matrix_delaymin = ".";
char message[64];
int messageLength = 0;
uint8_t data = A5;
uint8_t load = A4;
uint8_t myclock = A3;
unsigned long previousMillis = 0;
const long interval = 60000;
String MFSvalue;
String new_MFSversion;
String cur_MFSversion;
void setup() {
Spark.function("MFS", MFS);
//Matrix
led = new LedControl(data,myclock,load,8); //DIN,CLK,CS,HowManyDisplays
led-> shutdown(0,false); //Turn it on
led-> setIntensity(0,15);
strip.begin();
colorAll(strip.Color(153,0,255),0);
strip.show();
}
void loop() {
//Matrix display
if (matrixRun == true){
if(phase==0){ //Message-loop starts
char charBuf[50];
matrix_delaymin.toCharArray(charBuf, 50);
sprintf(message,"%s", charBuf); //update message
messageLength = strlen(message); // ...and length
led->tweenLetters(0,' ',message[phase], 50); //scroll from empty to 1 letter
}
if(phase<messageLength-1){ //next characters except last one
led->tweenLetters(0,message[phase],message[phase+1], 50);
phase++;
}else if(phase==messageLength-1){//last character scrolls to empty
led->tweenLetters(0,message[phase],' ', 10);
phase = 0; //restart message-loop
}
}
}
// this function called trough API
int MFS(String command)
{
int commaPosition = command.indexOf(",");
if(commaPosition>-1){
MFSvalue = "";
MFSvalue += command.substring(0,commaPosition);//first part
new_MFSversion = "";
new_MFSversion += command.substring(commaPosition+1, command.length());//second part
}
if(new_MFSversion != cur_MFSversion){
colorWipe(0,600);
cur_MFSversion = "";
cur_MFSversion = new_MFSversion;
}
//Build result code. (Success = 0, Success with warning = 1, Failed = 2)
if(MFSvalue == "0")
{
//success
colorWipe(strip.Color(0, 255, 0), 600); // Green
matrixRun = true;
led-> shutdown(0,false);
matrix_delaymin = new_MFSversion;
return 0;
} else
if(MFSvalue == "1")
{
//Success with warning
colorWipe(strip.Color(255, 50, 0), 600); // orange
matrixRun = true;
led-> shutdown(0,false);
matrix_delaymin = new_MFSversion;
return 1;
} else
if(MFSvalue == "2")
{
//Failed
colorWipe(strip.Color(255, 0, 0), 600); // red
matrixRun = true;
led-> shutdown(0,false);
matrix_delaymin = new_MFSversion;
return 2;
} else {
matrixRun = false;
led-> shutdown(0,true);
colorWipe(strip.Color(255, 0, 0), 600); // purple
return -1;
}
}
void colorAll(uint32_t c, uint8_t wait) {
uint16_t i;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
//delay(wait);
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
You can use powershell to send data to Particle;
$resrouce = "https://api.particle.io/v1/devices"
$apiKey = "1234567890"
$deviceID = "1234567890"
$function= "MFS"
$args= "0,Hello!"
$postParams = @{access_token=$apiKey;args=$args}
Invoke-WebRequest -Uri $resource"/"$deviceID"/"$function -Method POST -Body $postParams
I hope the project share inspires you all to get creative! Have fun!