Lab3 - The Cloud

Submitted by katehsiao on Mon, 02/18/2013 - 21:25

 

Description

The Cloud, a weather reporter.
Use a cotton to simulate the cloud in the sky.
 
Use 3 potentiometers to control the "temperature", "humidity", and "wind" to simulate the color of the cloud from a cloudy weather to a storm.
 
The cloud is blue when the weather is nice. It gradually becomes orange when the sun comes out (temperature gets high). Followed by the purple cloud due to rising humidity (before raining). Then the storm comes (high wind-speed) by changing the lighting frequency.
 

Components Used

1- Arduino Uno
1- Breadboard
3- LED (R,G,B)
3- 220Ω Resistor
1- cutton
3- potentiometer
 
 

Code 

 

/*
* Weather Cloud
* A0: temperture (light blue -> orange -> red)
* A1: humidity (light blue -> blue -> purple)
* A2: wind (change frequency)
*
* Created 18 Feb 2013
* Kate Hsiao
*/
 
// Analog pin settings
int aIn = 0;    // Potentiometers connected to analog pins 0, 1, and 2
int bIn = 1;    //   (Connect power to 5V and ground to analog ground)
int cIn = 2;  
 
// Digital pin settings
int aOut = 9;   // LEDs connected to digital pins 9, 10 and 11
int bOut = 10;  //   (Connect cathodes to digital ground)
int cOut = 11;  
 
// Values
int aVal = 0;   // Variables to store the input from the potentiometers
int bVal = 0;  
int cVal = 0;  
 
void setup()
{
  pinMode(aOut, OUTPUT);   // sets the digital pins as output
  pinMode(bOut, OUTPUT);   
  pinMode(cOut, OUTPUT); 
  Serial.begin(9600);     // Open serial communication for reporting
}
 
void loop()
{
 
  aVal = analogRead(aIn) / 4;  // read input pins, convert to 0-255 scale
  bVal = analogRead(bIn) / 4; 
  cVal = analogRead(cIn) / 4;  
 
  analogWrite(aOut, aVal);
  analogWrite(bOut, aVal/8);
  analogWrite(cOut, bVal/4);
  if (cVal>1) {
    delay(255-cVal);
    analogWrite(aOut, aVal/2);
    analogWrite(bOut, aVal/16);
    analogWrite(cOut, bVal/8);
    delay(255-cVal);
  }
 
}
 

Video

IMG_3774.jpg
0
Your rating: None
Drupal theme by Kiwi Themes.