#include <Adafruit_NeoPixel.h> //Neopixel libary for LED-Strips
#define numberofPixels 16
#define doornumberofPixels 15 // define number of pixels connected
Adafruit_NeoPixel strip(numberofPixels , 27, NEO_GRB + NEO_KHZ800); // define LED-Type and name it (numberofPixels connected, pin pixels are connected to, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel doorstrip(doornumberofPixels , 26, NEO_GRB + NEO_KHZ800);
//#define powerON 22 //if high
#define swo 28
#define sw1 22
bool ledsw = true;
bool dispsw = true;
int color = 0;
int speed = 200;
void setup() // setup for core 0
{
startup();
}
// loop core 0
void loop()
{
ledsw = digitalRead(swo);
dispsw = digitalRead(sw1);
if ( ledsw == true ) { rpmled(); } else {fadeled(); }
if ( dispsw == true ) { dooron(); } else {dooroff(); }
//
}
void dooron()
{
doorstrip.fill(strip.ColorHSV(color, 255, 255));
doorstrip.show();
}
void dooroff()
{
doorstrip.clear();
doorstrip.show();
}
void rpmled()
{
// light up strip according to engine rpm
//strip.clear();
strip.fill(strip.ColorHSV(map(2000, 0, 5200, 32000, 65535), 255, 255));
strip.show();
//
}
void fadeled()
{
// light up strip according to engine rpm
color = color + speed;
if (color >= 65535) color = 0;
strip.fill(strip.ColorHSV(color, 255, 255));
strip.show();
//
}
void startup()
{
//pinMode(powerON,INPUT_PULLUP)
pinMode(swo, INPUT_PULLDOWN);
pinMode(sw1, INPUT_PULLDOWN);
//NeoPixel strip.begin doorstrip
//wait until connection is ready
strip.begin();
strip.show();
// display pixels color
for(int i=0; i<numberofPixels; i++)
{
strip.setPixelColor(i, 200,200,200);
strip.show(); // Send the updated pixel colors to the hardware.
delay(60);
}
doorstrip.begin();
doorstrip.show();
// display pixels color
for(int i=0; i<doornumberofPixels; i++)
{
doorstrip.setPixelColor(i, 200,200,200);
doorstrip.show(); // Send the updated pixel colors to the hardware.
delay(60);
}
}
void turnoff()
{
for(int i=numberofPixels; i!=0; i--)
{
strip.setPixelColor(i, 0,0,0);
strip.show(); // Send the updated pixel colors to the hardware.
delay(40);
}
}
void tempalarm() // ALARM Display for to HIGH Engine collant temperature
{
// set leds to red
strip.fill(strip.ColorHSV(0, 255, 255));
strip.show();
//delay(142);
// turn off lights to become blinking red effect
strip.clear();
strip.show();
return loop();
}
void lowrpmalarm() // ALARM Display for to LOW RPM value
{
// set leds to red
strip.fill(strip.ColorHSV(0, 255, 255));
strip.show();
// turn off lights to become blinking red effect
strip.clear();
strip.show();
return loop();
}
void highrpmalarm() // ALARM Display for to HIGH RPM value
{
// set leds to red
strip.fill(strip.ColorHSV(0, 255, 255));
strip.show();
// turn off lights to become blinking red effect
strip.clear();
strip.show();
return loop();
}