Inflating and deflating

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
williamu
 
Posts: 3
Joined: Sun Feb 23, 2014 7:29 pm

Inflating and deflating

Post by williamu »

Hi all,

First time post here and novice re: arduino etc. I'm working with a student attempting to assist them in making an object that can inflate and deflate. We found this reference: https://www.adafruit.com/product/4699 and have followed a similar path. Right now, I've got a working circuit and basic program using an L293D motor controller, a Metro, and two air pump and vacuum motors. My simple program has one motor deflating for 5 seconds while the other is off and then the second motor inflating for 5 seconds while the other is off... on repeat. Now I'm wondering how I can incorporate this: https://www.adafruit.com/product/4699 6V air valve to create a mechanism that both pumps can inflate/deflate the same object.

The code is in an attached image, using Arduino IDE, as is a photo of my physical setup. Any help on how to approach the next steps would be super helpful!!!!

Thanks in advance, looking forward to some guidance.

Best,
Willie

User avatar
adafruit_support_bill
 
Posts: 85008
Joined: Sat Feb 07, 2009 10:11 am

Re: Inflating and deflating

Post by adafruit_support_bill »

To post your code, use the "</>" button above the edit window and paste the text between the tags.

User avatar
williamu
 
Posts: 3
Joined: Sun Feb 23, 2014 7:29 pm

Re: Inflating and deflating

Post by williamu »

Thanks! Here it is:

Code: Select all

// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
// Motor B connections
int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
	// Set all the motor control pins to outputs
	pinMode(enA, OUTPUT);
	pinMode(enB, OUTPUT);
	pinMode(in1, OUTPUT);
	pinMode(in2, OUTPUT);
	pinMode(in3, OUTPUT);
	pinMode(in4, OUTPUT);
	
	// Turn off motors - Initial state
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
	digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

void loop() {
	directionControl();
	delay(1000);
	speedControl();
	delay(1000);
}

// This function lets you control spinning direction of motors
void directionControl() {
	// Set motors to maximum speed
	// For PWM maximum possible values are 0 to 255
	analogWrite(enA, 255);
	analogWrite(enB, 255);

	// Turn on motor A DEFLATE for 5 seconds
	digitalWrite(in1, HIGH);
	digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
	delay(5000);
	//Turn on motor B INFLATE for 5 seconds
  digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
	digitalWrite(in4, HIGH);
	delay(5000);	
	

	// Turn off motor A Turn off motor B
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
	digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

// This function lets you control speed of the motors
void speedControl() {
	// Turn on motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, HIGH);
	digitalWrite(in3, LOW);
	digitalWrite(in4, HIGH);

	// Now turn off motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
	digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

User avatar
adafruit_support_bill
 
Posts: 85008
Joined: Sat Feb 07, 2009 10:11 am

Re: Inflating and deflating

Post by adafruit_support_bill »

To alternate between inflating and deflating, first you need to connect all the parts:

Connect the output of motor A to the rear metal port of the valve for inflating.
Connect the input of motor B to the side plastic port of the valve for deflating.
Connect the object you wish to inflate to the end plastic port.

You will also need a transistor (or another L293D) to drive the solenoid for the valve.
https://learn.adafruit.com/transistors- ... rs-2998941

To inflate, energize the valve and turn on motor A.
To deflate, de-energize the valve and turn on motor B.

User avatar
williamu
 
Posts: 3
Joined: Sun Feb 23, 2014 7:29 pm

Re: Inflating and deflating

Post by williamu »

Thanks so much for your help!

Would the TIP120 transistor and 1n4001 diode work for my setup? Slightly uncertain about wiring and programming if you have any references…

Would you suggest using https://www.adafruit.com/product/3297 the DRV8833 board instead? From what I understand all the parts I need are built into that board. If you think that’s a better route, do you have any coding references I can follow?

Thanks so much for your help Bill, happy holidays.

User avatar
adafruit_support_bill
 
Posts: 85008
Joined: Sat Feb 07, 2009 10:11 am

Re: Inflating and deflating

Post by adafruit_support_bill »

The TIP120 & 1N4001 would work fine. Wiring would be as shown in the link above. To turn it on, call: digitalWrite(pin, HIGH);
And to turn off, use:
digitalWrite(pin, LOW);

The DRV8833 would also work. You would connect the solenoid to just one leg of one of the H-Bridges.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”