Micro Archive

Useless Machine……part three

< Useless Machine Part two

Code for the useless machine:  download source file

You can download the file above or you can copy and paste from the file below. (more…)

Useless Machine……part two

< Useless Machine Part one
Useless Machine Part three >

As it stands this is a very simple circuit with very simple code.

Useless Machine Schematic

Useless Machine Schematic

Click for a larger image

The complete circuit fits on a piece of strip board 10 strips X 14 holes.

Strip board circuit for useless machine

Strip board circuit

Most of the parts came from Rapid Electronics. They are local to me which is very handy.

I picked up a bunch of cheap servos on ebay with no connectors. Resistors etc came from my parts bin. I used a much larger voltage regulator than was needed as I had it on hand. I have substituted a better spec’ed part in the parts list. I also used a battery holder with a battery clip and fly lead with clip. I have spec’ed a simple battery holder with fly leads in the parts list.

Parts List
Description Order code Cost
ATtiny85 73-5122 £3.38
Relay 5v spdt 60-0787 £1.14
Da78l05 V Reg +5v 100ma To-92 47-3612 £0.26
Toggle Switch 75-0082 £0.655
Battery Holder 4xAA 18-3695 £1.21
2N22222 npn transistor 81-0256 £0.24
Capacitor 47 uf Elec 11-0815 £0.09
Capacitor 47nf Ceramic 08-1030 £0.136
IC socket 8 pin (tube of 60) 22-0107 £1.63
3 Pin Header 22-0500 £0.037
Resistor 2k2 Parts bin Pennies
Resistor 1K Parts bin Pennies
Hobby Servo Ebay Cheap

All the build details and picture to come in the next posts………

On to post 3. The source code……..


Useless machine

 Useless Machine Part two >

A simple toy using an attiny85, a servo and a toggle switch.

The idea is simple. A toggle switch is mounted on the top of a box. When turned on, a ‘finger’ pops out of the box, turns the switch off then returns to the box leaving the machine in a powered off state.

The finger will be attached to a servo horn.  When the switch is turned on, the micro will fire up, turn on a relay that by-passes the switch. It will then rotate the servo to move the finger to operate the toggle switch. The micro will then retract the finger and turn off the relay removing power to the circuit.

The micro I intend to use is the attiny85. Why ? Cause I had a couple to play with.

Why ? cause I had just go hold of the USBtinyISP byLadyAda from .:oomlout:. and…. err…

OK, So I have a new toy and wanted a simple project to use it for. This seems pretty simple.  Two outputs, the servo and the relay. No inputs. 5 Volt regulator and a power switch.

I grabbed an attiny85 and my trusty UsbTinyIsp programmer. Bread board awaiting, I add an led, power through a switch to the rails (5 volt regulated from the Bench psu).

Connect up a servo to one of the pwm pins (PB0 or PB1) and away we go…….


My first problem is the code.

I can’t get a pwm generation going……..

Out with the scope.

Play with the code…


Reprogram chip…

Rerun program…

….and loop

After many iterations I get a working waveform.

Hook up the servo.

Trim the top and bottom values.


Working servo control.

After getting the servo to move I had to trim the output.  The attiny can drive a servo beyond its home and full rotation positions.  To get the most out of the servo the code needs to be adjusted so it gets close to full rotation with out hitting the end stops.  This stops the motors and gearboxes in the servo being damaged.

To trim the servo you could use a variable resistor connected to an analogue input. Read this and adjust the servo until correct then output the value some where.  Instead of this I just tried a few values, entering each one in the code and recompiling. Start with a value below the max and approach it bit by bit. When the servo does not move any further for and increase in value, back the value off by one and use that.

I may add a trim feature to the circuit and software.  If this sounds useful, let me know.

On to part 2. The hardware.


Powered by WordPress 4.9.4 | Theme MxS2