Here we have our final product. The rudders are not attached here, but they will be placed on top on the propulsion fan on the back. Hoover is ready for liftoff.
Arduino Project
Friday, December 12, 2014
Here we have the code for the hovercraft
//Code for the Fall 2014 Design Project
//Not Your Average Housecats' Hovercraft
//Libraries required for Motor Shield
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <Servo.h>
Servo rudder; // create servo object to control a servo
int buttonPin = 2;
int rudderPotPin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int buttonState;
int val2;
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *liftMotor = AFMS.getMotor(1);//Assign the lift motor to M1 port on Motor Shield
Adafruit_DCMotor *propulsionMotor = AFMS.getMotor(2);//Assign the propulsion motor to M2 port on Motor Shield
//Where are we putting the steering motors? What do we call them (surely not Adafruit_DCMotor)
void setup() {
Serial.begin(9600);
Serial.println("Hovercraft online.");
rudder.attach(10); //attaches rudder to pin 10
AFMS.begin();
//Turn on lift motor and set speed to maximum
liftMotor->setSpeed(255);
liftMotor->run(FORWARD);
pinMode(buttonPin, INPUT);
buttonState = digitalRead(buttonPin);
}
void loop(){
val2 = digitalRead(buttonPin);
if (val2 != buttonState) {
if (val2 == LOW) { // the button is not pressed...
Serial.println("Button just released");
propulsionMotor->setSpeed(0);
propulsionMotor->run(RELEASE);
} else { // the button is pressed...
Serial.println("Button just pressed");
propulsionMotor->setSpeed(255);
propulsionMotor->run(FORWARD);
}
}
buttonState = val2; // save new state in val2
val = analogRead(rudderPotPin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
rudder.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
//Code for the Fall 2014 Design Project
//Not Your Average Housecats' Hovercraft
//Libraries required for Motor Shield
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <Servo.h>
Servo rudder; // create servo object to control a servo
int buttonPin = 2;
int rudderPotPin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int buttonState;
int val2;
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *liftMotor = AFMS.getMotor(1);//Assign the lift motor to M1 port on Motor Shield
Adafruit_DCMotor *propulsionMotor = AFMS.getMotor(2);//Assign the propulsion motor to M2 port on Motor Shield
//Where are we putting the steering motors? What do we call them (surely not Adafruit_DCMotor)
void setup() {
Serial.begin(9600);
Serial.println("Hovercraft online.");
rudder.attach(10); //attaches rudder to pin 10
AFMS.begin();
//Turn on lift motor and set speed to maximum
liftMotor->setSpeed(255);
liftMotor->run(FORWARD);
pinMode(buttonPin, INPUT);
buttonState = digitalRead(buttonPin);
}
void loop(){
val2 = digitalRead(buttonPin);
if (val2 != buttonState) {
if (val2 == LOW) { // the button is not pressed...
Serial.println("Button just released");
propulsionMotor->setSpeed(0);
propulsionMotor->run(RELEASE);
} else { // the button is pressed...
Serial.println("Button just pressed");
propulsionMotor->setSpeed(255);
propulsionMotor->run(FORWARD);
}
}
buttonState = val2; // save new state in val2
val = analogRead(rudderPotPin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
rudder.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
We finally got the servo motors working. We have one potentiometer controlling two rudders, which we are going to use to steer the hovercraft. For the propulsion fan, we are going to use a button (not pictured) to turn the fan on and off. So far, the code is working well and the hoovercraft is looking like it's ready to take flight.
Here we have the two versions of our hovercraft. On the Left with the black skirt was our first design, which we abandoned because it was too large and heavy. On the right is our current design. We cut a lot of weight off the body and made a brand new skirt. We hope that it will be able to lift higher than the previous build.
Tuesday, December 9, 2014
Laser Cutting and Arduino Challenges
Mike and I went to the lab yesterday with two goals: get our rudders laser-cut and determine how we could power the fans from our Arduino.
The first task went fairly smoothly. We had originally wanted nice aerodynamic 3D-printed rudders for the hovercraft, but in the interest of time we went with a laser-cut version instead. We might need to get some thin wooden or metal dowels to help mount the chunkier acrylic rudders on the final craft. For the time being, it's comforting to know that our hovercraft will have a means to steer itself as it drifts majestically through the presentation hall.
Unfortunately, our second goal eluded us for the time being. We installed the appropriate libraries for the motor shield and connected the fan, but the code would not execute properly. More troubleshooting was needed to find a solution.
--Eric
The first task went fairly smoothly. We had originally wanted nice aerodynamic 3D-printed rudders for the hovercraft, but in the interest of time we went with a laser-cut version instead. We might need to get some thin wooden or metal dowels to help mount the chunkier acrylic rudders on the final craft. For the time being, it's comforting to know that our hovercraft will have a means to steer itself as it drifts majestically through the presentation hall.
Unfortunately, our second goal eluded us for the time being. We installed the appropriate libraries for the motor shield and connected the fan, but the code would not execute properly. More troubleshooting was needed to find a solution.
--Eric
Monday, December 8, 2014
Construction Progress
Monday, November 24, 2014
I found two computer fans today. One of the fans comes with a 300 watt power source, and the other is taken straight out of a computer. One will definitely be used as the downward facing fan, but we're not sure what we want to use as the propulsion fan yet. I also got a controller and a USB cable for controlling the hovercraft, but we may need a special shield to connect it to the Arduino in order to make it work.
Subscribe to:
Posts (Atom)