Back to Parent

int pin1 = D1;
int pin2 = D2;
int pin3 = D3;
int pin4 = D4;
int pin5 = D5;
int pin6 = D6;

int prewMoney = 0;

void setup() {
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);

Serial.begin(9600);

Particle.function("Spreadsheet", data);

}

void loop()
{

}

void light(int num)
{
for(int k=0;k<6;k++)
{
digitalWrite(k+1, LOW);
}
for(int i=0;i<num;i++)
{
digitalWrite(i+1, HIGH);
}
}


int data(String command)
{
int moneyNew = command.toInt();
Serial.print ("Your value is: ")
Serial.println(moneyNew);

light(0);
if(moneyNew >=100 && moneyNew <200)
{
light(1);
}else if(moneyNew >=200 && moneyNew <300)
{
light(2);
}else if(moneyNew >=300 && moneyNew <400)
{
light(3);
}else if(moneyNew >=400 && moneyNew <500)
{
light(4);
}else if(moneyNew >=500 && moneyNew <600)
{
light(5);
}else if(moneyNew > 600)
{
light(6);
}
return 1;
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0