Monday, September 29, 2014

Serial Communication

This is the programming that I used in order to write the Pythagorean theorem.

#include "math.h"               // include the Math Library

int a = 3;
int b = 4;
int h;

void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps

  Serial.println("Lets calculate a hypoteneuse");

  Serial.print("a = ");
  Serial.println(a);

  Serial.print("b = ");
  Serial.println(b);
 
  h = sqrt( a*a + b*b );
 
  Serial.print("h = ");
  Serial.println(h);
}

void loop()              
{
}

No comments:

Post a Comment