PHYSICAL COMPUTING

Projects

[Blink] [Runway] [Move] [Pixel Bend]

Project 3: Move

Description

This project consists in developing an interactive device that can be used to control any mechanism by a physical behavior with the help of motors. For my project, I decided to create a controller that allow to measure the intensity of strength implemented (in imaginary way) for the weightlifting

The materials needed for this projects are the following:

  1. 1 Arduino module
  2. 1 Sharp GPD2D12 IR ranger
  3. 1 Solderless breadboard
  4. 1 DC Motor
  5. 1 Speaker
  6. 1 H-Bridge
  7. 6 LED's
  8. 6 resistors

The schematic diagram for this project is the following

Figure 1


Procedure

This project shows us (in interactive way) how the individual can measure the intensity of his straight by lifting weights. While doing this, the motor start to turn (either in slow or fast way) depending on the measurements  got by the sensor

Figure 2

Figure 3

Code


int switchPin = 2;    // switch input
int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
int enablePin = 9;    // H-bridge enable pin
int ledPin = 13;      // LED
int i, irReader = 5;    // the analog input pin for the ir reader
int pins[] = { 5, 6, 7, 8, 10, 11 }; // an array of pin numbers
void setup() {
  // set the switch as an input:
  pinMode(switchPin, INPUT);
  // set all the other pins you're using as outputs:
  pinMode(motor1Pin, OUTPUT);
  pinMode(motor2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  for (i = 0; i < 6; i++)   // the array elements are numbered from 0 to num_pins - 1
    pinMode(pins[i], OUTPUT);      // set each pin as an output
}
void loop() {
  // if the switch is high, motor will turn on one direction:
  i = analogRead(irReader);
 
  if(i > 72 && i < 172)
      digitalWrite(pins[0], HIGH);
  else
      digitalWrite(pins[0], LOW);
  if(i > 172 && i < 272)
      digitalWrite(pins[1], HIGH);
  else
      digitalWrite(pins[1], LOW);
  if(i > 272 && i < 372)
      digitalWrite(pins[2], HIGH);
  else
      digitalWrite(pins[2], LOW);
  if(i > 372 && i < 472)
      digitalWrite(pins[3], HIGH);
  else
      digitalWrite(pins[3], LOW);
  if(i > 472 && i < 572)
      digitalWrite(pins[4], HIGH);
  else
      digitalWrite(pins[4], LOW);
  if(i > 572 && i < 672)
      digitalWrite(pins[5], HIGH);
  else
      digitalWrite(pins[5], LOW);
  digitalWrite(motor1Pin, LOW);
  digitalWrite(motor2Pin, HIGH);
  analogWrite(enablePin, i/2.625);
  delay(30);
}