Making Things Interactive

January 29, 2008

Its an amazing color changing light box!!

Filed under: 3: LadyAda Tutorials,Assignments,Christopher Bridgman — cbridgma @ 1:13 am

So here is my proof for completing the arduino tutorials. i have included a video of the color blending box project along with my code for it. I changed the timing of the code so the colors would last longer and you could see the colors longer. I also included the code for the last part of the 4th tutorial.

Code:

int redPin = 12;                  // Red LED connected to digital pin 12
int greenPin = 11;                // Green LED connected to digital pin 11
int bluePin= 10;                   // Blue LED connected to digital pin 10

void setup()                      // run once, when the sketch starts
{
  pinMode(redPin, OUTPUT);        // sets the digital pin as output
  pinMode(greenPin, OUTPUT);      // sets the digital pin as output
  pinMode(bluePin, OUTPUT);       // sets the digital pin as output
}

void loop()                       // run over and over again
{
  digitalWrite(redPin, HIGH);     // sets the Red LED on
  digitalWrite(greenPin, LOW);   // sets the Green LED off
  digitalWrite(bluePin, LOW);    // sets the Blue LED off
  delay(2000);                     // waits for half a second
  digitalWrite(redPin, HIGH);      // sets the Red LED on
  digitalWrite(greenPin, HIGH);    // sets the Green LED on
  digitalWrite(bluePin, LOW);    // sets the Blue LED off
  delay(2000);                     // waits for half a second
  digitalWrite(redPin, LOW);      // sets the Red LED off
  digitalWrite(greenPin, HIGH);    // sets the Green LED on
  digitalWrite(bluePin, LOW);    // sets the Blue LED off
  delay(2000);                     // waits for half a second
  digitalWrite(redPin, LOW);      // sets the Red LED off
  digitalWrite(greenPin, HIGH);    // sets the Green LED on
  digitalWrite(bluePin, HIGH);    // sets the Blue LED on
  delay(2000);                     // waits for half a second
  digitalWrite(redPin, LOW);      // sets the Red LED off
  digitalWrite(greenPin, HIGH);    // sets the Green LED on
  digitalWrite(bluePin, HIGH);    // sets the Blue LED on
  delay(2000);                     // waits for half a second
  digitalWrite(redPin, LOW);      // sets the Red LED off
  digitalWrite(greenPin, LOW);    // sets the Green LED off
  digitalWrite(bluePin, HIGH);    // sets the Blue LED on
  delay(2000);                     // waits for half a second
  digitalWrite(redPin, HIGH);      // sets the Red LED on
  digitalWrite(greenPin, LOW);    // sets the Green LED off
  digitalWrite(bluePin, HIGH);    // sets the Blue LED on
  delay(2000);                     // waits for half a second
}

Code for 4th tutorial:

int drive_gb = 100;
long drive_mb;
long drive_kb;
long real_drive_mb;
long real_drive_kb;
void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps

  Serial.print(“Your HD is “);
  Serial.print(drive_gb);
  Serial.println(” GB large.”);

  drive_mb = drive_gb;
  drive_mb = drive_mb * 1024;
  drive_kb = drive_mb * 1024;
 
  Serial.print(“In theory, it can store “);
  Serial.print(drive_mb);
  Serial.print(” Megabytes, “);
  Serial.print(drive_kb); 
  Serial.println(” Kilobytes.”);

  real_drive_mb = drive_gb;
  real_drive_mb = real_drive_mb * 1000;
  real_drive_kb = real_drive_mb * 1000;
 
  Serial.print(“But it really only stores “);
  Serial.print(real_drive_mb);
  Serial.print(” Megabytes, “);
  Serial.print(real_drive_kb); 
  Serial.println(” Kilobytes.”);
 
  Serial.print(“You are missing “);
  Serial.print(drive_kb – real_drive_kb); 
  Serial.println(” Kilobytes!”);
}

void loop()                       // run over and over again
{
}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: