Project showcase

Balloon cart with Proportional Deceleration © GPL3+

A cart with a balloon is pulled toward a wall of spikes and must come to a stop within 2 centimeters without the balloon popping.

  • 609 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

Project for my System Controls class at Cal Poly Pomona. The cart and balloon are pulled up the incline via a motor. The motor speed is controlled with pulse width modulation and decreases proportionally with its distance from the wall of nails through use of an ultrasonic sensor. Once the cart is within 2 centimeters of the spikes it reverses back down the ramp. The wall of nails is able to be manually moved anywhere along the Velcro rails without changing the system performance.

Code

Code to control motor shield proportionally with an ultrasonic range finder Arduino
Apologies for this code not being as simple consolidated as I could've made it but printing to the serial monitor helps with debugging the system when tuning.
#include <AFMotor.h>    //Adds Motor shield library

#define trigPin 7
#define echoPin 6  

float v;
int duration;
long distance;
long distance1;
long distance2;

AF_DCMotor motor(1);

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  motor.setSpeed(200);
  motor.run(RELEASE);
}

void loop() {
  do{
  distance = (duration/2) /29.1; 
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) /29.1;
  Serial.print("distance ");
  Serial.print(distance);
  Serial.println("cm");
  }while(distance <= 4 || distance > 40);

 do{
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance1 = (duration/2) /29.1;
  Serial.print("distance1 loop ");
  Serial.print(distance1);
  Serial.println("cm");
  delay(100);
  v = ((float)distance1/(distance+1))*255;
  Serial.print("speed ");
  Serial.println(v);
  motor.run(FORWARD); 
  motor.setSpeed(v);
  Serial.println("Forward");
 }while(distance1 > 5);

motor.run(RELEASE);
motor.setSpeed(0);
delay(3000);

do{
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance2 = (duration/2) /29.1;
  Serial.print("distance2 loop 2 ");
  Serial.print(distance2);
  Serial.println("cm");
  Serial.println("Backward");
  motor.run(BACKWARD);
  motor.setSpeed(150);
}while(distance2 <= 19);
motor.run(RELEASE);
delay(3000);
}

Comments

Similar projects you might like

Arduino Atari Adaptor

Project tutorial by Dante Roumega

  • 7,781 views
  • 6 comments
  • 25 respects

RPi GPIO Programming Using Arduino Web IDE

by WGLabz

  • 461 views
  • 0 comments
  • 4 respects

Generating Audio with an Arduino and a Resistor Ladder DAC

Project showcase by 3 developers

  • 2,792 views
  • 5 comments
  • 7 respects

Arduino Pendulum Physics Lab

Project tutorial by Paul Kassebaum

  • 1,328 views
  • 0 comments
  • 3 respects

Automated Plant Watering System

Project in progress by Ammar Shahid

  • 582 views
  • 0 comments
  • 5 respects

Humidity Measuring Molecule

Project showcase by KatjaNiggl

  • 1,510 views
  • 4 comments
  • 15 respects
Add projectSign up / Login