Week 3: Leave me Alone Box- Toby Nalder & Dom Heyland

Since dismantling our pre-bought annoying box last week, we have attempted to recreate the action of the arm using an arduino and code. Using a guide we found online we created a setup using a push button, potentiometer, dc motor and a L293D chip.

The guide used: https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/overview

Breadboard Layout:

learn_arduino_fritzing.png

Code:

int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
int switchPin = 7;
int potPin = 0;

void setup()
{
 pinMode(in1Pin, OUTPUT);
 pinMode(in2Pin, OUTPUT);
 pinMode(enablePin, OUTPUT);
 pinMode(switchPin, INPUT_PULLUP);
}
void loop()
{
int speed = analogRead(potPin) / 4;
boolean reverse = digitalRead(switchPin);
 setMotor(speed, reverse);
}
void setMotor(int speed, boolean reverse)
{
 analogWrite(enablePin, speed);
 digitalWrite(in1Pin, ! reverse);
 digitalWrite(in2Pin, reverse);
}

Below is a YouTube video of our setup working, using the gear arrangement from the box we bought to give the arm more torque.

As you can see from the video we used the gear arrangement from the box we bought to give the arm more torque to turn a switch off. This setup works so that the arm reverses when the button is held down, so if we replaced it with a switch it would return back into the box when the switch was turned off.

For next week we need to look into a way to  make the arm stop rotating once it has hit the switch, we are also starting to design the box all the components are going to be housed in.