Monday, September 26, 2011

Waters getting Warmer

For the most recent Smart Surfaces project, I have focused on using the Arduino to program two functions.  The first function is that of a solar tracker, which uses to light sensitive diodes, compares the values being received by each, and then rotates the motor to simulate the rotation of a pv panel.

http://www.youtube.com/watch?v=nAPEt7WguIM

Light Tracker Code 

void loop()
{{
  //lightLevelL Left
 int lightLevelL = analogRead(lightPinL); //Read the
 Serial.println (" lightLevel left is "); 
 Serial.println (lightLevelL);
 Serial.println (", ");
 lightLevelL = map(lightLevelL, 0, 180, 0, 200);
         //adjust the value 0 to 900 to
         //span 0 to 255
        
//lightLevelR  Right
 int lightLevelR = analogRead(lightPinR); //Read the
 Serial.println (" lightLevel right is "); 
 Serial.println (lightLevelR);
 Serial.println (", ");

lightLevelR = map(lightLevelR, 0, 200, 0, 200);
         //adjust the value 0 to 900 to
         //span 0 to 255
       
 // Reset the position of the servo

 if (lightLevelL > lightLevelR)
  {
 Serial.println (" lightLevelL is greater than lightLevelR"); 
    positionNew = positionCurrent + 10;
   for(positionCurrent = 0; positionCurrent < positionNew; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
    positionCurrent = positionNew; //update the position of the servo
  }
  }
 
else if (lightLevelL < lightLevelR)
  {
  Serial.println (" lightLevelR is greater than lightLevelL"); 
  positionNew = positionCurrent - 10;
  for(positionCurrent = 0; positionCurrent < positionNew; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
     delay(15);                       // waits 15ms for the servo to reach the position
    positionCurrent = positionNew; //update the position of the servo
}


Water's Getting Warmer Code

The second function is one that gauges the temperature of the water and communicates this to the interior using a blue light for cold water and a red light for warm water.  This light is not only seen as informational but also contributing to the atmosphere of the interior.


void loop()                     // run over and over again
{
 float temperature = getVoltage(temperaturePin);  //getting the voltage reading from the temperature sensor
 temperature = (temperature - .5) * 100;          //converting from 10 mv per degree wit 500 mV offset
                                                  //to degrees ((volatge - 500mV) times 100)
 Serial.println(temperature);                     //printing the result
//temperature = map(temperature, 20, 30, 0, 10);
         //adjust the value 0 to 900 to
         //span 0 to 255
 tempNew = temperature;
// Serial.println(tempNew);  
 delay(1000);                                     //waiting a second

 if (tempNew > tempCurrent)
 {
   Serial.println ("Water is getting Hotter");
   redNew = redCurrent + 20; 
   blueNew = blueCurrent - 20;      
    digitalWrite(ledPinRed, redNew);   // RED LED
    digitalWrite(ledPinBlue, blueCurrent);   // BLUE LED
  //digitalWrite(ledPinGreen, HIGH);  // GREEN LED
   redCurrent = redNew;
   blueCurrent = blueNew;
  //delay(1000);
  tempCurrent = tempNew;
 }

  if (tempNew < tempCurrent)
 {
   Serial.println ("Water is getting Colder");
   redNew = redCurrent - 20;
   blueNew = blueCurrent + 20;    
    digitalWrite(ledPinRed, redNew);   // RED LED
    digitalWrite(ledPinBlue, blueCurrent);   // BLUE LED
  //digitalWrite(ledPinGreen, HIGH);  // GREEN LED
  redCurrent = redNew;
  blueCurrent = blueNew;
  tempCurrent = tempNew;
 
  //delay(1000);
 
  //digitalWrite(ledPinRed, LOW);    // set the LED off
 // digitalWrite(ledPinBlue, LOW);    // set the LED off
//  digitalWrite(ledPinGreen, LOW);    // set the LED off
 // delay(1000);              // wait for a second
 }

   if (tempNew = tempCurrent)
 {
   Serial.println ("Constant Temperature");
   tempCurrent = tempNew;
 }


Physical Prototype


Also part of my task was to investigate possible mechanisms for the Arduino.  Ben HD took a stronger role in this as we moved from concept to fabrication.




Other links:

http://www.projectione.com/radiance/

http://lebbeuswoods.wordpress.com/2011/01/26/four-ideal-houses-first-year-studio-2/

www.alphapure.net/wxcontest/weather_art.htm
 

No comments:

Post a Comment