Project showcase
Balloon cart with Proportional Deceleration

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.

  • 708 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

Pathfinder

Project showcase by Team Maverick

  • 23,799 views
  • 15 comments
  • 121 respects

Inflate With A Broken Balloon

Project tutorial by HomeMadeGarbage

  • 1,064 views
  • 1 comment
  • 7 respects

Obstacle Avoiding Car

Project showcase by Adam

  • 5,744 views
  • 1 comment
  • 18 respects

Red Balloon Carbon Monoxide Detector

Project tutorial by circuito.io team

  • 4,730 views
  • 3 comments
  • 24 respects

TIC TAC DUINO

Project showcase by BaruchTeam,

  • 1,616 views
  • 1 comment
  • 3 respects

Hot Air Balloon or Weather Satellite Navigation System

Project tutorial by Patel Darshil

  • 1,758 views
  • 0 comments
  • 14 respects
Add projectSign up / Login