Aquarium kit assistance

Light system and pr

Made by Xi

A simple prototype that could be applied to aquarium kit. In the daytime (while the light is adequate), there is no light; when the light gets darker - in the evening, the light color switches randomly among red, green and blue; when it gets even darker - coming to night, the light color varies to any color randomly. (P.S. The color looks soft and suuuuuuuuuuuuuper cute in the dark!!!!!) Another function of the prototype is the pressure. When too much pressure is applied to the sensor because of the fish's metabolism, a line of red lights would be turn on for warning.

Created: January 28th, 2015

0

Goal:

1. Turning on the lights inside the aquarium kit automatically when it's getting dark, and makes the color varies at night for aesthetic purpose.  

2. When the pressure inside the aquarium kit gets high, turn on several red LED for warning.


0
/****************RGB LED**************/
int redPin = A1;
int greenPin = D1;
int bluePin = D0;

int colors[3] = {255,255,255};

/************light sensor**************/
int photoCellPin = A0;
int ledPin = D7;
int photoCellReading = 0;

/************force sensor**************/
int forcePin = A6;
int forceCellReading = 0;
int redLedLinePin = A5;



int debugValue = 0;

void setup()
{
  /************setting LED************/
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  pinMode(redLedLinePin, OUTPUT);

  digitalWriteColor();

  /********setting photosensor********/
  pinMode(ledPin, OUTPUT);

  /**********report to cloud**********/
  //Spark.function("led",ledControl);
  Spark.variable("light", &photoCellReading, INT);
  Spark.variable("force", &forceCellReading, INT);
  Spark.variable("red", &colors[0], INT);
  Spark.variable("green", &colors[1], INT);
  Spark.variable("blue", &colors[2], INT);
  Spark.variable("debug", &debugValue, INT);
//  RGB.color(redV, greenV, blueV);
}

void loop()
{
  /****reading the value of light sensor****/
  photoCellReading = analogRead(photoCellPin);
  forceCellReading = analogRead(forcePin);

  /****random the color while the light changing****/
  if(photoCellReading > 200 && photoCellReading < 1000)
    ledSingleColorRandom();
  if(photoCellReading <= 200)
    ledAllColorRandom();
  else
    {
      digitalWriteColor();
      debugValue = 0;
    }
  /**** the force ****/
  if(forceCellReading > 1000)
    analogWrite(redLedLinePin, random(0, 255));
  if(forceCellReading <= 1000)
    analogWrite(redLedLinePin, 0);
}


/********when the light gets dark (200 - 1000)********/
/********the RGB LED blink randomly********/
/********BUT COLOR BY COLOR********/
void ledSingleColorRandom()
{
  int randomValue = random(0, 255);
  int whichColor = random(1,100)%3;

  //colors[0] = randomValue;
  colors[whichColor] = randomValue;

  debugValue = 1;
  digitalWriteColor();

  delay(1000);
  /********set all color's value back********/
  /****!!don't forget it!!!! Setting back here****/
  for(int i = 0; i <3; i++)
  {
    colors[i] = 255;
  }
}


/********when the light gets dark (0 - 200)********/
/********the RGB LED blink randomly********/
/********ALL COLOR********/
void ledAllColorRandom()
{
  for(int i = 0; i <3; i++)
  {
    colors[i] = random( 0, 255);
  }

  debugValue = 2;
  digitalWriteColor();

  delay(800);
  /********set all color's value back********/
  /****!!don't forget it!!!! Setting back here****/
  for(int i = 0; i <3; i++)
  {
    colors[i] = 255;
  }
}

/********write the value to each color********/
void digitalWriteColor()
{
  analogWrite(redPin,colors[0]);
  analogWrite(greenPin,colors[1]);
  analogWrite(bluePin,colors[2]);
}
Click to Expand
x
Share this Project


About

A simple prototype that could be applied to aquarium kit. In the daytime (while the light is adequate), there is no light; when the light gets darker - in the evening, the light color switches randomly among red, green and blue; when it gets even darker - coming to night, the light color varies to any color randomly. (P.S. The color looks soft and suuuuuuuuuuuuuper cute in the dark!!!!!)

Another function of the prototype is the pressure. When too much pressure is applied to the sensor because of the fish's metabolism, a line of red lights would be turn on for warning.