I am new to coding and am working on a weather project for school. Whenever I flash my code, the light becomes solid cyan and I have to flash tinker every time to fix it. I think it has to do with the coding because when I flash the codes that use IFTTT it just becomes unreachable. Can anyone show me what the issue is with my code?
// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal_I2C_Spark.h>
#include <neopixel.h>
LiquidCrystal_I2C *lcd;
String Hightemp = "70";
String Lowtemp = "50";
String Ctemp = "60";
String command = "Cloudy";
SYSTEM_MODE(AUTOMATIC);
// Define colors (R, G, B)
#define PEACH 200,50,5
#define CYAN 10,150,70
#define PURPLE 180,3,180
#define BLUE 20,20,255
#define WHITE 255,255,255
#define GREEN 10,180,10
#define YELLOW 200,150,0
#define LIGHTBLUE 135,206,250
#define INDIGO 75,0,130
#define OFF 10,180,10
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 15
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int i = 0;
int weather = 0;
void setup()
{
Serial.begin(9600);
lcd = new LiquidCrystal_I2C(0x27,16,1);
lcd->init();
lcd->backlight();
lcd->clear();
// register the Particle function
Particle.function("screen", LedAansturing);
Serial.begin(9600);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop()
{
lcd->setCursor(1,0);
lcd->print(Hightemp);
lcd->setCursor(5,0);
lcd->print(Ctemp);
lcd->setCursor(9,0);
lcd->print(Lowtemp);
// weather functies
if(weather == 1)
{
// RAIN
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, INDIGO);
}
strip.show();
}
else if(weather == 2)
{
// SNOW
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, WHITE);
}
strip.show();
}
else if(weather == 3)
{
// CLOUDY
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, BLUE);
}
strip.show();
}
else if(weather == 4)
{
// CLEAR
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, YELLOW);
}
strip.show();
}
else if(weather == 5)
{
// OFF
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, GREEN);
}
strip.show();
}
else
{
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, CYAN);
}
strip.show();
}
}
// this function automagically shows up in IFTTT
int LedAansturing(String command1)
{
int plusLoc = command1.indexOf('+');
int ampLoc = command1.indexOf('&');
int atLoc = command1.indexOf('@');
//
if (plusLoc != -1) //if we were able to find a '+' in the string
{
String commandB = command1.substring(0, plusLoc);
Hightemp = commandB;
}
else //otherwise, if we couldn't find a plus sign, set Hightemp to "N/A"
{
Hightemp = "N/A";
}
//
if (ampLoc != -1) //if we were able to find a '+' in the string
{
String commandC = command1.substring(plusLoc+1, ampLoc);
Lowtemp = commandC;
}
else //otherwise, if we couldn't find a plus sign, set Hightemp to "N/A"
{
Lowtemp = "N/A";
}
//
if (atLoc != -1) //if we were able to find a '+' in the string
{
Ctemp = command1.substring(ampLoc+1, atLoc);
command = command1.substring(atLoc+1);
}
else //otherwise, if we couldn't find a plus sign, set Hightemp to "N/A"
{
command = "Cloudy";
}
//
Serial.println("Weather update received");
Serial.println(command);
if(command == "Rain" || command == "Raining" || command == "Rain Shower" || command == "Thunderstorms" || command == "Light Rain")
{
weather = 1;
}
else if(command == "Light Snow" || command == "Snow" || command == "Snowing")
{
weather = 2;
}
else if(command == "Cloudy" || command == "Mostly Cloudy" || command == "Partly Cloudy" || command == "Fair")
{
weather = 3;
}
else if(command == "Clear" || command == "Clear Skies" || command == "Sunny")
{
weather = 4;
}
else
{
weather = 5;
}
}