Back to Parent

int redPin1 = A0;    // RED pin of the LED to PWM pin **A0**
int bluePin1 = D0;   // BLUE pin of the LED to PWM pin **D1**

int redPin2 = D1;
int bluePin2 = A1;

int greenPin3 = A4;    // RED pin of the LED to PWM pin **A0**
int bluePin3 = A5;   // BLUE pin of the LED to PWM pin **D1**

int greenPin4 = A6;
int bluePin4 = A7;

int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255

void setup()
{
  // Set up our pins for output
  pinMode( redPin1, OUTPUT);
  pinMode( bluePin1, OUTPUT);

  pinMode( redPin2, OUTPUT);
  pinMode( bluePin2, OUTPUT);

  pinMode( greenPin3, OUTPUT);
  pinMode( bluePin3, OUTPUT);

  pinMode( greenPin4, OUTPUT);
  pinMode( bluePin4, OUTPUT);

  //Register our Spark function here
  Spark.function("none", setNone);
  Spark.function("yoga", setYoga);
  Spark.function("cardio", setCardio);
  Spark.function("weights", setWeights);

  // turn them all off...
  //analogWrite( redPin, redValue);
  //analogWrite( greenPin, greenValue);
  //analogWrite( bluePin, blueValue);
}

int setNone(String dummy)
{
  // 6 leds for protein, 8 leds for grain, 6 leds for veggies
  analogWrite( redPin1,0);      // one more protein
  analogWrite( bluePin1,255);

  analogWrite( redPin2,255);    // one more grain
  analogWrite( bluePin2, 0);

  analogWrite( greenPin3,255);  // two more grains
  analogWrite( bluePin3,0);

  analogWrite( greenPin4,255);
  analogWrite( bluePin4, 0);
}


int setYoga(String dummy)
{
  // 5 leds for protein, 7 leds for grain, 8 leds for veggies
  analogWrite( redPin1,255);      // two more grains
  analogWrite( bluePin1,0);

  analogWrite( redPin2,255);
  analogWrite( bluePin2, 0);

  analogWrite( greenPin3,0);    // two more veggies
  analogWrite( bluePin3,255);

  analogWrite( greenPin4,0);
  analogWrite( bluePin4, 255);
}

int setCardio(String dummy)
{
  // 6 leds for protein, 6 leds for grains, 8 leds for veggies
  analogWrite( redPin1,0);      // one more protein
  analogWrite( bluePin1,255);

  analogWrite( redPin2, 255);    // one more grain
  analogWrite( bluePin2, 0);

  analogWrite( greenPin3,0);    // two more veggies
  analogWrite( bluePin3,255);

  analogWrite( greenPin4,0);
  analogWrite( bluePin4, 255);

}

int setWeights(String dummy)
{
  // 7 leds for protein, 5 leds for grain, 8 leds for veggies
  analogWrite( redPin1,0);      // two more proteins
  analogWrite( bluePin1,255);

  analogWrite( redPin2, 0);
  analogWrite( bluePin2, 255);

  analogWrite( greenPin3,0);   // two more veggies
  analogWrite( bluePin3,255);

  analogWrite( greenPin4,0);
  analogWrite( bluePin4, 255);
}
Click to Expand

Content Rating

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

0