Making Things Interactive

January 30, 2008

tutorials complete!

Filed under: 3: LadyAda Tutorials,Gaku Sato — ponkotsu @ 1:19 am

// here’s my tutorial 04 drivecalc code 

int drive_gb = 100;
long drive_kb_1024;
long drive_kb_1000;

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

  Serial.print(“Your drive capacity is “);
  Serial.print(drive_gb);
  Serial.println(“GB.”);

  drive_kb_1024 = drive_gb;
  drive_kb_1024 = drive_kb_1024 * 1024 * 1024;
  Serial.print(“This translates to “);
  Serial.print(drive_kb_1024);
  Serial.println(“KB.”);
 
  drive_kb_1000 = drive_gb;
  drive_kb_1000 = drive_kb_1000 * 1000 * 1000;
  Serial.print(“Unfortunately, a “);
  Serial.print(drive_gb);
  Serial.print(“GB drive can only store “);
  Serial.print(drive_kb_1000);
  Serial.println(“KB,”);
  Serial.print(” which is actually “);
  Serial.print(drive_kb_1000 / 1024 / 1024);
  Serial.println(“GB.”);
 
  Serial.print(“This means you are missing “);
  Serial.print(drive_kb_1024 – drive_kb_1000);
  Serial.print(“KB or “);
  Serial.print(drive_kb_1024 / 1024 – drive_kb_1000 / 1024);
  Serial.println(“MB.”);
}

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

Create a free website or blog at WordPress.com.

%d bloggers like this: