Wednesday, March 23, 2011

Arm's lengthWearable technology Presentation

Last week we presented our wearable technology project, Arm's Length.  Unfortunately, the Arduino shield gave us some problems and we were not able to incorporate it into the shirt we prepared for it.


//Author: Bruce Allen
//Date: 23/07/09
//Modified by A.Lopez breadboardsareus.blogspot.com with blink light code

//Digital pin 7 for reading in the pulse width from the MaxSonar device.
//This variable is a constant because the pin will not change throughout execution of this code.
const int pwPin = 7;
//variables needed to store values
long pulse, inches, cm;

void setup() {

//This opens up a serial connection to shoot the results back to the PC console
Serial.begin(9600);
pinMode(13, OUTPUT); //attaches LED to pin 13
pinMode(12, OUTPUT); //attaches LED to pin 12
pinMode(11, OUTPUT); //attaches LED to pin 11

}

void loop() {

pinMode(pwPin, INPUT);
int val;  // variable to store pulse value

//Used to read in the pulse that is being sent by the MaxSonar device.
//Pulse Width representation with a scale factor of 147 uS per Inch.

pulse = pulseIn(pwPin, HIGH);
//147uS per inch
inches = pulse/147;
//change inches to centimetres
cm = inches * 2.54;

val = cm;

if (val < 20 && val > 1){
  Serial.println("brazil");
digitalWrite(10, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(10, LOW); // set the LED off
}


if (val < 40 && val > 20){
 Serial.println("canada");
digitalWrite(12, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(12, LOW); // set the LED off
}


if (val < 60 && val > 40){
  Serial.println("india");
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
}


Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();

delay(500);

}

No comments:

Post a Comment