Mhm... Look interesting. Actually, that is what I'm doing, all I use for "intelligence" in my project are Arduini. I just build what I can myself, because it saves money. Also, building things is fun, especially if you look forward to what you're gonna use them for.
My magnet finally arrived. Works good, can be switched using a BC337 (max I = 800 mA) and using 9 Volts, it perfecly suits me "needs". At the moment, I'm running a 1 hour test with my "proven to work"-Screwdriver-Plastic Surface-Audio Emitter. I'll update this post when the test is over.
So, here it is: The Hardware Revision 1 of the MSBD Magnet Release...
Material- Arduino Mini Pro 5V (for perfboarding)
- Arduino Uno (for breadboarding)
- A BC337 Transistor
- A 4,7 kOhm Resistor
- An Electromagnet
- Solder
- A perfboard
- Wires
- A battery Clip (the 9V block type)
- An 8 Cell Battery holder
- 8 rechargable Batteries (1.2 Volts)
Tools- Soldering Iron
- Wire Cutter
- Deisolation tool (optional, can use knife)
- A solderless breadboard (optional though you can
Skills- Through-Hole-Soldering
- Breadboarding
- Basic Electronics
- Basic Programming
What to do
What we build will basically be a so called emitter circuit. Since we cannot supply 250 mA the magnet requires with our tiny Arduino board, we need an external power supply and a transistor to switch it off/on.
This means that we need a common ground between the Arduino and the magnet. In case you never worked with transistors before, common ground means that whatever is powering the base and whatever is powering the collector goes to the same ground (-/black). This is essential, you can't build two grounds in here.
If the digital Pin (8) of the Arduino goes high, the magnet turns on. Once it goes LOW, the magnet turns off and drops its load (= keys).
If you don't change any of the values (use 9.6 V Power Supply, 250 mA/12V Electro Magnet), you can use all the parts I wrote above. Otherwise, calculations beyond the scope of this guide are needed.
Leave some space on the board. It'll recieve a 433 Mhz receiver later on, since it will be the "bootstrap" device for our network code.
It is recommended that you first draft the circuit on a solderless breadboard, to understand what to connect to what in which way.
Connect:
1. Battery Clip Ground / Vcc to Breadboard Ground/Vcc. DO NOT CONNECT THE BATTERY YET!
2. The Wires of the Magnet to two seperate lanes of the breadboard
2.1 One Electromagnet Wire to Vcc
2.2 The other Electromagnet Wire to the Collector of the transistor.
3. Connect the Transistor
3.1 The 4.7 kOhm Resistor to the Base of the transistor.
3.2 Ground to the Emitter of the transistor.
4. Connect the Battery. Nothing should happen. Magnet: Off.
5. Disconnect the Battery.
Upload the program to the arduino. Note that it is a testing program.
Code:
#define TIMELOCKED 5
#define RELEASEPIN 8
unsigned long timerStatus = 0;
unsigned long timerRelease = (unsigned long)TIMELOCKED * 1000;
void setup() {
pinMode(RELEASEPIN, OUTPUT);
digitalWrite(RELEASEPIN, HIGH);
Serial.begin(9600);
}
void loop() {
timerStatus = millis();
if (timerStatus > timerRelease) {
digitalWrite(RELEASEPIN, LOW);
}
delay(1000);
}
Now, disconnect the Arduino from your PC (we will power it via the Battery holder).
6. Connect the Arduino to the breadboard (exactly in this order!!!)
6.1. Connect Pin 8 to the resistor.
6.2. Connect VIN on the Arduino to Vcc on the breadboard.
6.3. Connect GND on the Arduino to GND on the breadboard.
7. Hold something of iron below the magnet and reset the arduino.
The magnet should start attracting something, and after five to six seconds, drop it again.
If this worked out, solder it onto a perfboard. After that, upload the second test script.
Code:
#define TIMELOCKED 60
#define RELEASEPIN 8
unsigned long timerStatus = 0;
unsigned long timerRelease = (unsigned long)TIMELOCKED * 1000*60;
void setup() {
pinMode(RELEASEPIN, OUTPUT);
digitalWrite(RELEASEPIN, HIGH);
Serial.begin(9600);
}
void loop() {
timerStatus = millis();
if (timerStatus > timerRelease) {
digitalWrite(RELEASEPIN, LOW);
}
delay(1000);
}
This should hold the key for one hour. If anything goes wrong (more than 5 seconds of difference, key not falling, key falling to early), the device is ready to go.
Failure Cases
The following failures should be safely handled:
- Failure of power supply (Key falls down)
- Transistor reaching junction Temp (Breaks/Key falls down)
- Magnet melting (Breaks/Key falls down)
- Programming error (Key falls down once batteries are empty)
Regarding the power supply
Use rechargeable batteries. The device is designed for handling currents up to 10 Volts safely. Although 12 Volts are technically possible, it is close to what the Arduino can take. Let one battery have half a Volt more, and it'll burn.
Using Rechargeable batteries will still let you have 10 Volts (9.6), which is safe under all conditions.
I'll upload a photo later on - can't take pics right now.