Introduction: The Different Useless Machine
With so many useless machines around, I tried to make one which is a bit different.
Instead of having a mechanism pushing back the toggle switch, this machine simply rotates the switch 180 degrees,
In this project I used a Nema 17 steppermotor, which is probably a bit overqualified, but it was lying around so why not use it?
Step 1: How It Works?
This machine is Arduino powered. When the switch is toggled the Arduino gets a signal and the steppermotor rotates the switch, which is connected to the steppermotor, 180 degrees. When toggled again the switch rotates 180 degrees back, so that the connected wires don't get twitched.
The whole machine is powered by a 12V DC adaptor. You could also power it with a 9V battery, but i'd advise you to take a smaller steppermotor like the 28-BJY48 in that case.
Step 2: The Parts..
you will need:
- an Arduino ( I used the good old Uno)
- a NEMA 17 stepper motor
- a motordriver, I used de L298N
- a small toggle switch which fits into the ballbearing
- a ballbearing 608Z
- a 12V power socket
- a 12V power supply
- some M3 bolts
- some jumper wires
in the dowloads here you will find a:
- STL of a spacer to put between the Arduino/the motordriver and the mounting plate
- STL of a connector to put the switch on the steppermotor
- STL of a holder to keep de NEMA steppermotor in place
These STL's can be used in a 3D printer.
Materials used (offcourse you can use other materials for the box etc, like plywood)
- 2.9mm acrylic plate for the box
- 6 mm acrylic plate for the base of the box
- some PLA for the 3Dprinted parts
- some superglue
- soldering tin
Step 3: The Tools I Used..
For cutting the acrylic for the box I used a 60W lasercutter, but you kan make any box you want, als long as it has the right dimensions.
For mounting the whole thing together, I used a 2.5mm drill and a M3 thread tap set. But I guess you can find other ways to put things together.
For the printed parts I used an Ultimaker 2+, but any 3D printer or printing service will do.
For soldering parts together I used a solderingstation.
Step 4: Creating the Box..
You can use any box you want, as long as the inside dimensions are 150x100x100 mm where the height is very important, the length and width can be larger if you want to.
As I mentioned earlier I used a lasercutter to cut acrylic plate for the box. If you want to do that as well, you can download the drawing for the box here, or create your own using one of those online boxmakers like
In the exact middle of the top plate of the box you make a hole of 22mm, so the ball bearing will fit in nicely.
I gave the bearing a bit of superglue to fix it in the top hole.
For the power inlet you create another hole in one of the sides.
I created 2,5 mm holes in the sides of the bottom plate en used the thread tapset to make M3 thread to connect the upper box to the plate.
In my bottom plate, which has a thickness of 6mm, I drilled another view holes 2,5 mm at the place where the Arduino, motordriver and steppermotor should be mounted and gave them some M3 thread as well. To mount the Arduino and motordriver I used spacers which I 3D printed.
Off course, you can also use double sided tape or glue or other mounting options.
Finally, I made a cover plate for the box, to cover the ball bearing and to put the words "ON" and "OFF".
This cover plate is 105.5 x 155.5 mm and has a 12 mm hole in the exact middle.
I used another acrylic plate to create it and engraved the letters with the lasercutter, but off course you can do this in many different ways.
I glued the cover plate on top of the box with some superglue.
Step 5: Schematic
Above is the schematic (drawn using Fritzing ).
The toggle switch has it's middle connection connected to the GND off the Arduino, then the to outer connections are connected to pin 4 and 6 of the arduino.
The 12V power inlet is connected to the motordriver as well to the Arduino. I soldered the wires direct to the Arduino, but you can use a 12V Power plug as well.
Step 6: The Code
In order to write code for Arduino, you need the Arduino IDE or the Arduino Web Editor (download or use it here )I am using the version 1.8.13. just make sure to select the correct COM port (windows) and board type from within the IDE or Web Editor, then use the downloaded code, and hit upload.
In order for the machine to work well you'll have to put the switch in ON position before plugging it in.
This because when plugged in, the machine rotates 180 one time. I haven't figured out yet how to avoid this in the code.. If someone has a solution i'll be happy to know!
17 Comments
3 years ago
Oh, for THIS Useless Machine - I'd definitely get a BIGGER ON / OFF switch!
3 years ago
You have used a two-way switch where a simple on-off switch would do. In your sketch forget about buttonBpin: either the switch is at position A and that input pin is LOW or the switch is the other way and the input is HIGH.
#include <Stepper.h>
#define STEPS 2000
Stepper myStepper(STEPS, 8, 9, 10, 11);
int buttonApin = 4;
bool buttonAstatus = LOW; // good programming practice
bool previous = LOW; // to initialise variables on declaration
void setup()
{
myStepper.setSpeed(500);
pinMode(buttonApin, INPUT_PULLUP);
buttonAstatus = previous = digitalRead(buttonApin);
}
void loop()
{
buttonAstatus = digitalRead(buttonApin);
if (buttonAstatus != previous) // switch has changed
{
delay(1100);
myStepper.step(STEPS);
previous = buttonAstatus; // reset status
digitalWrite(8, LOW); //for less power consumption
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
}
Reply 3 years ago
Am I missing something? It looks like this only turns the stepper motor in one direction, which will twist the wires to destruction pretty quickly.
Reply 3 years ago
No, you are quite right. It was myself that was missing something (sorry, but bear in mind that I'm not in the position of having built the machine). It occurred to me in bed last night what was going to go wrong.
Here is the amended code;
void loop()
{
buttonAstatus = digitalRead(buttonApin);
if (buttonAstatus != previous) // switch has changed
{
delay(1100);
int whichWay = STEPS;
if (previous == HIGH) whichWay = -whichWay;
myStepper.step(whichWay);
previous = buttonAstatus; // reset status
digitalWrite(8, LOW); //for less power consumption
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
}
Reply 3 years ago
Peter,
I've not built the machine either, nor have I programmed an arduino (not to say I've not done lots of programming over the years).
Your approach is perfect.
That being said (and this is a stylistic thing), I'd initialise whichWay to STEPS at the beginning of the setup code (i.e. once only), and where you have your if statement, remove it so you end up with simplified code with repeated execution of whichWay = -whichWay.
Also, seeing the four digitalWrite statements in a row hurts my brain. I'd stick those in a for loop.
so, something like this:
---
void setup()
{
whichWay = STEPS;
// plus all the other existing setup stuff.
}
void loop()
{
buttonAstatus = digitalRead(buttonApin);
if (buttonAstatus != previous) // switch has changed
{
delay(1100);
whichWay = -whichWay;
myStepper.step(whichWay);
previous = buttonAstatus; // reset status
for (int pin = 8; pin < 11; pin++) {
digitalWrite(pin, LOW); //for less power consumption}
}
}
---
Again, a lot of this is arguably style over substance :)
Reply 3 years ago
Thank you. I agree it's a matter of style. My approach is to use local variables rather than global, wherever possible, but you have certainly simplified the loop.
Reply 3 years ago
Thanks Peter, I see how it works!
3 years ago
It looks funny. But I believe the real useless machine must cut itself out of power at the end of the cycle.
Tip 3 years ago
Bart, the reason it spins 180 on start up is because your code sets
int switchSideA = 0;
int switchSideB = 0;
In the setup proc, after you read the two statuses, set the switchSideA and B variables appropriately, so the system is in the correct state.
BTW - I'd actually re-write the whole thing to use one Switch Status variable and one Side variable. See if you can work out how - you can do it with two variables and no else statement quite easily (and even retain the clockwise/counter clockwise turning of the switch)
Reply 3 years ago
Thanks for the Tip! I was going to figure it out, but Peter above here already did it form me.. It's all clear now.
3 years ago
I like this new version of the Useless Machine (hmmmm, I wonder if you could combine the 2 different types!!) I wonder if going back to analogue wouldn't make this a lot cheaper - a regular 12V motor and gears that run until they reach an endstop???
Keep up the good work!
Reply 3 years ago
Combining is a good plan indead! maybe with this guy's machine: https://www.instructables.com/id/The-Most-Useless-...
Cheaper is definitely possible, but like I said, I had the Nema lying around doing nothing :-).
I'm building one powered by a 9v battery now, that one has the 28BYJ-28 stepper in it, also a lot cheaper!
3 years ago
haha nice I like it! It happens in our house every time my wife uses the microwave
3 years ago
That's a unique approach to the useless machine design world. It's great. I would expect one could easily modify the design to use a 180° servo in place of the stepper motor, perhaps reducing costs.
3 years ago
A delightfully devious design. I love it.
3 years ago
Nice out of the box thinking!
3 years ago
Cool