Description:
In this project, I used a DC motor to launch plastic balls. It is in the shape of a round tower with flower decoration. The launcher can be activated using a force sensing resistor, and the speed of the launch can be set using a potentiometer.
Thus, this project took the "Output" assignment very seriously :)
Components used:
- (1) Arduino Uno
- (1) Breadboard
- (1) DC Motor
- (1) 3V Battery Pack
- (2) AA Batteries
- (1) FSR
- (1) Potentiometer
- (1) Diode (1N4004)
- (1) Transistor (TIP120)
- (1) Resistor (1k Ohms)
- (1) Resistor (10k Ohms)
- (2) Paper cups
- (several) Plastic balls
- (several) Cables
Code:
/*
* FlowerTower
*
* A tower that will launch small balls when activated,
* using a DC motor with an arm inside a round casing.
*
* The tower is activated using a FSR.
* A potentiometer is used to set the speed of the motor, and
* thus the energy with which the ball is launched.
*
* by Clemens Meyer <clemens.meyer@ischool.berkeley.edu>
*
* based on AnalogInput Arduino tutorial
* by DojoDave <http://www.0j0.org>, modified again by dave
*/
int potPin = 0; // select the input pin for the potentiometer
int fsrPin = 5; // select the input pin for the FSR
int motorPin = 9; // select the pin for the Motor
int speed = 0; // variable to store the value coming from the sensor
int pressure = 0;
int pressureThreshold = 400; // set a threshold for the FSR
void setup() {
Serial.begin(9600);
}
void loop() {
speed = analogRead(potPin); // read the value from the potentiometer, between 0 - 1023
pressure = analogRead(fsrPin); // read the value from the FSR, between 0 - 1023
// Print current speed and pressure for debugging
Serial.print("Speed: \t");
Serial.print(speed);
Serial.print("\t\t");
Serial.print("Pressure: \t");
Serial.println(pressure);
if (pressure > pressureThreshold) {
analogWrite(motorPin, speed/4); // If pressure sensor is activated, start launcher motor
}
else {
analogWrite(motorPin, 0); // Else, stop launcher motor.
}
}
- Login to post comments