Making Things Interactive

January 29, 2008

Assignment 3: Lady Ada Tutorials

Filed under: 3: LadyAda Tutorials,Assignments,Thomas Hendrickson — tphendrickson @ 2:34 pm

It took me a while to get the arduino program up and running… it seemed to be some problem with the current software so I used an older version (Arduino 0009).

Here’s my code for the blinking lights, it blinks three different LEDs in succession:

int redPin = 13;
int greenPin = 11;
int bluePin = 12;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void loop()
{
digitalWrite(redPin, HIGH);
delay(200);
digitalWrite(redPin, LOW);
digitalWrite(bluePin, HIGH);
delay(200);
digitalWrite(bluePin, LOW);
digitalWrite(greenPin, HIGH);
delay(200);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, HIGH);
delay(200);
digitalWrite(bluePin, LOW);

}

Here’s my solution for the kilobyte calculator:

int drive_gb = 100;
long drive_mb;
long real_mb;
long drive_kb;
long real_kb;

void setup()
{
Serial.begin(9600);

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;

real_mb = drive_gb;
real_mb = real_mb * 1000;
real_kb = real_mb * 1000;

Serial.print(“It can store “);
Serial.print(drive_mb);
Serial.println(” Megabytes!”);
Serial.println();

Serial.print(“Your HD should be able to hold “);
Serial.print(drive_kb);
Serial.println(” Kilobytes.”);
Serial.println();

Serial.print(“But it actually can only hold “);
Serial.print(real_kb);
Serial.println(” Kilobytes.”)
Serial.println();

Serial.print(“This is a difference of “);
Serial.print(drive_kb – real_kb);
Serial.println(” Kilobytes”);
}

void loop()
{

}

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

Blog at WordPress.com.

%d bloggers like this: