Assignment 4.1

Post date: Jul 28, 2010 1:9:22 AM

This assignment was fairly simple. It only required minor adjustments form the code given in the tutorial. I used many of the same commands that made the final result in the serial monitor visually appealing. This is my modified code:

#include "math.h" //includes the math library

/* sets up the variables for the problem. "a" and "b" are the legs.

"c" is the hypoteneuse. we will be solving for "a".

*/

int a;

int b = 4;

int c = 5;

void setup() //run once, when the sketch starts

{

Serial.begin(9600); //sets up the Serial Library at 9600 bps

/* All of the "Serial.print" or "Serial.println" commands have tell

the Arduino to write the phrase in phrase in quotes following the

command in the serial monitor */

Serial.println("Let's calculate a leg!");

Serial.print ("b = ");

Serial.println(b);

Serial.print("c = ");

Serial.println(c);

a = sqrt(c*c - b*b); //tells the Arduino to solve for the missing leg

Serial.print("a = ");

Serial.println(a);

}

void loop() // does nothing, but still neccessary

{

}