Advanced Useless Machine

120K48293

Intro: Advanced Useless Machine

Hi everyone today I'd like to present my unusual useless machine. I hope everyone heard about useless machine, but I built advanced version with seven toggle switches.

The idea of doing this box came up the husband of my cousin. As approached their wedding, I decided to do this them as a gift.

Elements I used:

  • Microcontroller Atmega8
  • capacitors (electrolytic and ceramic)
  • resistors to reset pin
  • quartz 16MHz
  • connectors
  • many wires
  • DC motor driver L298
  • 7 toggle switches
  • limit switch
  • power connector
  • two wires supply switch
  • power supply - I have witch four wires - GND, "-", 5V/2A, 12V/2A
  • two servos - I dismantled from old toy
  • stepper motor
  • from old printer
  • rail on which the carriage moves - also from old printer
  • arm - I made of the nail
  • boards, screws, hinges, timbers - everything needed to build the box

STEP 1: Box Construction

Build my box started by gathering all the items I needed. It included elements from old printer, motors, servos, etc. Many items I took from recycling. At first I had to found old printers. I asked my friends and they gave me three printers. outside stepper motor and rail I dismantled capacitors and many wires. Testing my elements lasted a very long time. I wrote testing programs for servos, stepper motor, switches. When I was sure that all working I started to build wooden box. Everything else I bought at a DIY store.

For this I used:

  • Planed board(?) with dimensions 2000mm x 80mm x 15mm (78" x 3.14" x 0.5")
  • Planed board(?) with dimensions 2000mm x 120mm x 15mm (78" x 4.7" x 0.5")
  • Timbers with dimensions 2000mm x 30mm x 15mm (78" x 1.2" x 0.5")

Also I needed two hinges and many screws Torx T25.

My rail is 400mm(15.7") long so size of my box is:

  • Width 430mm (17")
  • Height 120mm (4.7")
  • Length 160mm (6.3")

Before installing all the elements in box I had to adapt the stepper motor to the transtainer. Originally there was DC motor with perforated tape and encoder. Unfortunately I had problems reading value of the encoder, so I exchanged DC motor on stepper motor from another printer.

The next step was the location in the box all the elements. At the beginning Of the two wooden beams I have placed transtainer.

I screwed on the sides another two timbers and to one fitted a servo, which open the flap, while the second contactor. Then I drilled holes for switches. Construction of the box was finished.

STEP 2: Electronics

From the power supply 12V I connected by the L298 driver to stepper motor. At first I wanted to use L293 driver but it too much warming because my stepper motor receiver 2A.

5V I used to supply logic part and servos. I started tests on a breadboard. When everything worked I moved everything on the prototype board.

Program on Atmega I wrote in Arduino IDE. At the begin I wanted to do it in C in Eclipse, but I didn't have experience. (program code) In a large summary, box starts its operation in position "0", while holding the contactor. when is more switches on , flap does not close. If it turn of all the switches flap closes and a few empty loops scanning, arm returns to position "0".

STEP 3: Program

Program on Atmega I wrote in Arduino IDE. At the begin I wanted to do it in C in Eclipse, but I didn't have
experience.

CODE

Program code is not so complicated. If you know a little bit C language or Arduino IDE you can understand everything.

In a large summary, box starts its operation in position "0", while holding the contactor. when is more switches on , flap does not close. If it turn of all the switches flap closes and a few empty loops scanning, arm returns to position "0".

STEP 4: Conclusion


I built this useless machine for almost 3 months. Sometimes I had a big problems, which took me many days to solve, but I'm so proud of my box. It got me so much pleasure and knowledge during building it.

I know that article is not so long but I'm from Poland and I'm not writing in my language. If you have some questions, please ask me in the comments section, I will try to answer :)

83 Comments

Here is the code if someone needs it. source:https://majsterkowo.pl/bezuzyteczne-pudelko-wersja...

#include <Servo.h>
#define ramie 9
#define klapa 10
#define P1 0
#define P2 1
#define P3 2
#define P4 3
#define P5 4
#define P6 5
#define P7 6
#define S1 7
#define S2 8
#define S3 11
#define S4 12
#define K1 13
Servoservoram;//serwo ramie
Servoservoklap;//serwo otwieranie
intpoz=0;//pozycja silnika
intpetla=0;//petla do pozycji 0
intd=2500;// delay
intp=13;//ilość cykli
boolpoz_ram=0;
voidsetup()
{
Serial.begin(9600);
pinMode(ramie,OUTPUT);
pinMode(klapa,OUTPUT);
servoram.attach(ramie);
servoklap.attach(klapa);
servoram.write(0);
servoklap.write(75);
delay(700);
servoram.detach();
servoklap.detach();
pinMode(P1,INPUT);
pinMode(P2,INPUT);
pinMode(P3,INPUT);
pinMode(P4,INPUT);
pinMode(P5,INPUT);
pinMode(P6,INPUT);
pinMode(P7,INPUT);
pinMode(S1,OUTPUT);
pinMode(S2,OUTPUT);
pinMode(S3,OUTPUT);
pinMode(S4,OUTPUT);
pinMode(K1,INPUT);
digitalWrite(S1,LOW);
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
digitalWrite(S4,LOW);
while(digitalRead(K1)<HIGH)//powrót do początkowej pozycji
{
lewo(1);
}
wyl_sil();
}
//*******************************WYSUŃ RAMIĘ*********************************
voidwys_ramie()
{
servoram.attach(ramie);
servoram.write(140);
if(poz_ram==0)
{
delay(400);
}
else
{
delay(200);
}
}
voidwsun_ramie_pol()
{
servoram.write(55);
delay(200);
poz_ram=1;
}
voidwsun_ramie_cale()
{
servoram.write(0);
delay(200);
servoram.detach();
poz_ram=0;
}
//*****************************OTWARCIE*************************************
voidotwarcie()
{
servoklap.attach(klapa);
servoklap.write(135);
delay(300);
}
//***************************ZAMKNIECIE**************************************
voidzamkniecie()
{
servoklap.write(75);
delay(300);
servoklap.detach();
}
//************************KALIBRACJA*********************************
voidpoprawkap()
{
switch(poz)
{
case3:
prawo(1);
break;
case6:
prawo(1);
break;
case7:
prawo(1);
break;
}
}
voidpoprawkal()
{
switch(poz)
{
case3:
lewo(1);
break;
case6:
lewo(1);
break;
case7:
lewo(1);
break;
}
}
//******************************PRAWO******************************************
intprawo(intxp)
{
for(intj=0;j<xp;j++)
{
digitalWrite(S1,HIGH);
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
digitalWrite(S4,LOW);
delayMicroseconds(d);
digitalWrite(S1,LOW);
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
digitalWrite(S4,LOW);
delayMicroseconds(d);
digitalWrite(S1,LOW);
digitalWrite(S2,HIGH);
digitalWrite(S3,LOW);
digitalWrite(S4,HIGH);
delayMicroseconds(d);
digitalWrite(S1,HIGH);
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
digitalWrite(S4,HIGH);
delayMicroseconds(d);
}
}
intlewo(intxl)
{
for(inti=0;i<xl;i++)
{
digitalWrite(S1,LOW);
digitalWrite(S2,HIGH);
digitalWrite(S3,LOW);
digitalWrite(S4,HIGH);
delayMicroseconds(d);
digitalWrite(S1,LOW);
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
digitalWrite(S4,LOW);
delayMicroseconds(d);
digitalWrite(S1,HIGH);
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
digitalWrite(S4,LOW);
delayMicroseconds(d);
digitalWrite(S1,HIGH);
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
digitalWrite(S4,HIGH);
delayMicroseconds(d);
}
}
//**************************************WYLACZ SILNIK*********************************
voidwyl_sil()
{
digitalWrite(S1,LOW);
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
digitalWrite(S4,LOW);
}
voidprzyc1()
{
if(digitalRead(P1)==HIGH)
{
petla=0;
przycisk1();
}
}
voidprzyc2()
{
if(digitalRead(P2)==HIGH)
{
petla=0;
przycisk2();
}
}
voidprzyc3()
{
if(digitalRead(P3)==HIGH)
{
petla=0;
przycisk3();
}
}
voidprzyc4()
{
if(digitalRead(P4)==HIGH)
{
petla=0;
przycisk4();
}
}
voidprzyc5()
{
if(digitalRead(P5)==HIGH)
{
petla=0;
przycisk5();
}
}
voidprzyc6()
{
if(digitalRead(P6)==HIGH)
{
petla=0;
przycisk6();
}
}
voidprzyc7()
{
if(digitalRead(P7)==HIGH)
{
petla=0;
przycisk7();
}
}
//*************************************START*******************************************
voidstart()
{
if(poz==0)
{
prawo(5);
poz++;
}
}
//1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
voidprzycisk1()
{
start();
if(poz>1)
{
while(poz>1)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==1)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P1)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//2222222222222222222222222222222222222222222222222222222222222222222222222222222222
voidprzycisk2()
{
start();
if(poz<2)
{
while(poz<2)
{
prawo(p);
poz++;
poprawkap();
}
}
if(poz>2)
{
while(poz>2)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==2)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P2)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//33333333333333333333333333333333333333333333333333333333333333333333333333
voidprzycisk3()
{
start();
if(poz<3)
{
while(poz<3)
{
prawo(p);
poz++;
poprawkap();
}
}
if(poz>3)
{
while(poz>3)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==3)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P3)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//44444444444444444444444444444444444444444444444444444444444444444444444444444
voidprzycisk4()
{
start();
if(poz<4)
{
while(poz<4)
{
prawo(p);
poz++;
poprawkap();
}
}
if(poz>4)
{
while(poz>4)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==4)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P4)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//55555555555555555555555555555555555555555555555555555555555555
voidprzycisk5()
{
start();
if(poz<5)
{
while(poz<5)
{
prawo(p);
poz++;
poprawkap();
}
}
if(poz>5)
{
while(poz>5)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==5)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P5)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//666666666666666666666666666666666666666666666666666666666666666666666666
voidprzycisk6()
{
start();
if(poz<6)
{
while(poz<6)
{
prawo(p);
poz++;
poprawkap();
}
}
if(poz>6)
{
while(poz>6)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==6)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P6)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//7777777777777777777777777777777777777777777777777777777777777777777777777777
voidprzycisk7()
{
start();
if(poz<7)
{
while(poz<7)
{
prawo(p);
poz++;
poprawkap();
}
}
if(poz>7)
{
while(poz>7)
{
lewo(p);
poprawkal();
poz--;
}
}
if(poz==7)
{
if(servoklap.read()!=135)
{
otwarcie();
}
while(digitalRead(P7)!=LOW)
{
wys_ramie();
wsun_ramie_pol();
}
}
}
//****************************************LOOP******************************
voidloop()
{
//servoram.detach();
//servoklap.detach();
przyc1();
przyc2();
przyc3();
przyc4();
przyc5();
przyc6();
przyc7();
przyc6();
przyc5();
przyc4();
przyc3();
przyc2();
przyc1();
petla++;
delay(2);
if(petla==2)
{
wsun_ramie_cale();
zamkniecie();
}
if(petla==100)
{
while(digitalRead(K1)<HIGH)
{
lewo(1);
}
wyl_sil();
petla=0;
poz=0;
}
}
Can you add the code as a file on your instructables? The web domains are expired. Thanks!
Hi mysior103, first of all thanks for the tutorial and for sharing the code. I have a question regarding the k1 switch. Where is this switch placed in the box? I don't see it in the pictures. Thanks again.
Hi, switch K1 is at the begin of the arm. It checks if arm is on the start position.
Thanks mysior103. I finally got mine to work. Thanks again for everything. I will post a video as soon as I finish. I used a cd-rom drive's stepper motor.
Hi, switch K2 checks if arm is on start position. On the attached picture I pointed where it is placed.
Thanks mysior103 for your prompt response. Now I can see k1, but where in the code is k2? and what kind of switch is it? Thanks again!

Is this what will take the place of steering wheels after self driving cars hit the road?

No.
That would be self-driving ambulances. Followed by self-driving hearses.

How can I get above source code file?

Hey,
Looks and works great but please re-post the code so i can have a peak.
Thanks,
Ian

English version of source code please, Google translate didn't help me with it, such as what is "frame", "flap", and other words? Thanks if you can help with this. larystoy

Very nice machine. The link for the code is not working anymore. Do you still have the code thanks

Insanely cool!

For power saving (if wanted)
Replace power switch with a push-button. Push button bypasses a relay contact to give power to the microcontroller. Fist thing the microcontroller does is power on the relay, which now becomes the "power on" switch. After delay, arduino powers off the relay, disconnecting it from power completely (ZERO power draw). I did this in my "vampire killer" project - there is a schematic there for this complete power off / push button to start" circuit.

More Comments