Thursday, February 9, 2012

How to solve for a side of a triangle

/* * Math is fun! */ #include "math.h" // include the Math Library int a = 3; int b; int h = 5; void setup() // run once, when the sketch starts { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Lets calculate a side of the triangle"); Serial.print("a = "); Serial.println(a); b = sqrt( h*h - a*a ); Serial.print("b = "); Serial.println(b); Serial.print("h = "); Serial.println(h); } void loop() // we need this to be here even though its empty { }

Wednesday, February 8, 2012

Code to make a for loop go there and back

void setup() // run once, when the sketch starts { // even though there's nothing in it } // we still need this process void loop() // run over and over again { for (int ledPin = 10; ledPin >= 2; ledPin = ledPin-1) // Declares ledPin, { // tests if equal to or greater than 8 // then does the following. It repeats // but decreases the value of ledPin by 1 pinMode(ledPin, OUTPUT); // sets the digital pin as output digitalWrite(ledPin, HIGH); // sets the LED-ledPin on delay(100); // waits for a tenth of a second digitalWrite(ledPin, LOW); // sets the LED-ledPin off } for (int ledPin = 2; ledPin <= 10; ledPin = ledPin+1) // Declares ledPin, { // tests if equal to or greater than 8 // then does the following. It repeats // but decreases the value of ledPin by 1 pinMode(ledPin, OUTPUT); // sets the digital pin as output digitalWrite(ledPin, HIGH); // sets the LED-ledPin on delay(100); // waits for a tenth of a second digitalWrite(ledPin, LOW); // sets the LED-ledPin off } }

Friday, February 3, 2012

This is the code to make lights on a breadboard go back and forth


/*
  Blink
 
 Turns on an LED on for one second, then off for one second, repeatedly.
 
 The circuit:
 * LED connected from digital pin 13 to ground.
 
 * Note: On most Arduino boards, there is already an LED on the board
 connected to pin 13, so you don't need any extra components for this example.
 
 
 Created 2  February  2012
 By Robert Kurkowski
 
 http://arduino.cc/en/Tutorial/Blink
 
 based on an orginal by H. Barragan for the Wiring i/o board
 
 */

int ledPin = 2 ;    // LED connected to digital pin 2
int ledPin2= 3;     // Led conntected to digetal pin 3
int ledPin3=4;      // led connected to digital pin 4
int ledPin4=5;      // led connected to digital pin 5
int ledPin5=6;      // led connected to digital pin6
int ledPin6=7;      // led connected to digital pin 7
int ledPin7=8;      // led connected to digital pin 8
int ledPin8=9;      // led connected to digital pin 9

// The setup() method runs once, when the sketch starts

void setup()   {                
  // initialize the digital pin as an output:
   pinMode(ledPin, OUTPUT); 
   pinMode(ledPin2, OUTPUT);
   pinMode(ledPin3, OUTPUT); 
   pinMode(ledPin4, OUTPUT);
   pinMode(ledPin5, OUTPUT);
   pinMode(ledPin6, OUTPUT);
   pinMode(ledPin7, OUTPUT);
   pinMode(ledPin8, OUTPUT);
    
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                     
{
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin2, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin2, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin3, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin3, LOW);    // set the LED off
  delay(100);                  // wait for a second
  
  digitalWrite(ledPin4, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin4, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
  digitalWrite(ledPin5, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin5, LOW);    // set the LED off
  delay(50);                  // wait for a second
   
   digitalWrite(ledPin6, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin6, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin7, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin7, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin8, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin8, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
  
   digitalWrite(ledPin7, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin7, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin6, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin6, LOW);    // set the LED off
  delay(50);                  // wait for a second
   
   digitalWrite(ledPin5, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin5, LOW);    // set the LED off
  delay(50);                  // wait for a second
   
  
  
   digitalWrite(ledPin4, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin4, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin3, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin3, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
   digitalWrite(ledPin2, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin2, LOW);    // set the LED off
  delay(50);                  // wait for a second
  
 
}

Tuesday, January 17, 2012

This Arduino Project is turn signals for your biking jacket. it is simple to make, you make it by programming the arduino to activate when pushing a switch in the sleeve. When the button is pushed it will cause the lights on the back to blink.

Laser Harp

This project is cool because of the noise the machine makes when a person hits a laser. This is done by the lasers are interrupted by the persons hand and a mirror picks up the signal and plays the noise.