This tutorial will explain a simple way to make a password protected bluetooth door lock using your Arduino, which can be unlocked by sending a four digit pin from your Android phone! The hardware setup is quite simple, and the programming side of it is a bit tricky, but should be no problem for any Arduino ameuture.
Remove these ads by
Signing UpStep 1: Parts Needed
2. Electric Door Strike
3. Bluetooth Module ($9.99)
4. Power Supply (Required voltage and amperage differs among different door strikes/locks)
5. TIP120 Transistor
6. 1N4001 Diode
7. Hookup Wire
8. Solderless Breadboard
9. An Android phone (optional, considering that there are lots of devices you could use to send serial data to our bluetooth modem including Iphones, computers, and other Bluetooth devices)











































Visit Our Store »
Go Pro Today »




the system should work without any commands need to be send(in the project above we must send 'ABCD' to activate the relay) from the phone.
hope you can help me by giving some solution. much appreciated your help..
I am using Arduino UNO, in this case is there any difference on the command line and I am using Arduino 1.5.2 to upload the command. Please give me more detail on this project.
Can I suggest my pfodApp ( www.pfod.com.au ) as an alternative Android App
Using pfodApp allows you to customize the mobile's display to present the user with a named button.
No Andriod programming is required, just a simple text message from the Arduino.
www.pfod.com.au has example code for a Garage Door opener which can be easily reused to drive the lock, by changing the "Garage Door" text in the Arduino code to "Front Door Lock"
Collin if you would like to contact me, we could talk about a non-english (UTF8) version of pfodApp.
I'm using a 9v battery instead of a power supply
Is this ok?....:
int buttonPin = 2;
int ledPin = 13;
int lock = 9; //pin 9 on Arduino
int buttonState = 0;
void setup() {
pinMode(lock, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(lock, HIGH);
pinMode(ledPin, OUTPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
digitalWrite(lock, LOW);
delay(5000);
}
else {
digitalWrite(ledPin, LOW);
digitalWrite(lock, HIGH);
}
delay(500);
}
The program should give an audible signal to show code received otherwise you get multiple presses as users have no feedback.
Likewise you could offer audible feedback that the lock is open.
What happens if the power fails whilst the lock is open, there isn't anyway to re-lock it unless the mechanism has a mechanical default of closed.
A standard door isn't much of a deterrent to a determined person.
Anything you can carry will be taken locked and opened later with a sledge hammer.
Steve
When the current flowing in an inductor is forced to stop, the voltage across its terminals can rise to many tens or even hundreds of volts. The diode ensures that the current has an alternative path to flow through, as the transistor is switched off. Now, the maximum voltage across the coil is around 1V.
You should use a decent rectifier diode like the 1N4007.
Steve
2.) Forget the resistor - you can't do better for braking than a shortcircuit.
3.) You still need a diode on the load, to prevent radiated noise.
Steve
Just an example equation ignoring friction: if there are five amps flowing in a motor that has a inductive load around 2 ohms. Then power would be I^2 * R which would be 25 square amps * 2 ohms which would be 50 watts.
If i re-do the equations with five amps and a 100 ohm resistor accross the terminals of the motor (technically it would be 100 resistive and 2 inductive which ends up about 100.0199) then it would be 25 square amps * 100 ohms of impedance which is 2500 watts.
Just a small example of how a braking resistor brakes. Is it always necessary? nope. Can it be helpful and make your motor stop a LOT quicker? Yup. In my example the motor will stop around 50 times faster.
by the way on the diode i thought you were meaning accross the motor and being triggered by the relay. You can see in my diagram that i still included the diode across the output to prevent my relay from hurting my 'duino.
Oh and by the way if you search a website like mouser for relays limited the search to 5v and 40 mA (the specs for my 'duino's output). I got around 73 results
and just to make it fit my example i limited it to 5 Amps on the contacts. I still had multiple results
....Just saying
There is no such thing as "inductive resistance" There is only inductive reactance. Reactance is NON-dissipative. The dissipation mechanism is resistive losses in the motor winding.
Firstly, your maths. Taking your example.
"5 amps across 2 Ohms" = 10V. (supply volts, say)
Dissipation = 50W.
NOW.
Motor voltage = 10 V (imposed by the supply) resistance = 100 Ohms, power dissipation = 100/100 = 1 Watt. Current is now 10/100 = 100mA.
Your math fails. ADDING external resistance REDUCES the load on the motor !!!
And, OK, Add an INFINITE resistor, which by your specious argument would be THE best possible load ! Leave the pins of the motor open ! Does it now stop FASTER than when its shorted ? Of course not.
If this is a Duo or Duemilenova, DON'T blow your arduino up by running at Absolute maximum rating - the recommended limit is 20mA, and the sum of all pin currents must be <100mA. This is at a maximum package
temperature of 25 C, so derate accordingly at temperatures above that.
....just saying.
Steve
By your math i have a 10V motor, fine no problem. Still dissapates the 50W i said.
Below that you are not following what i said. What you are describing sounds like you are puttting the motor in parallel with the resistor? i dont know why you would want to do that. now if you were to put the resistor in series to limit the current or something like that it would make more sense.
what i am saying is that if you just open the terminals of the motor ( or short them with a resistor) all of the back EMF that is generated is only dissapated by the friction and internal coils in the motor. thats pretty much just coasting to a stop.
the resistor dissapates the power in the motor more quickly than the friction and the internal wiring would. The catch is that the resistor should only be accross the terminals when the motor is not being powered.
By the way the reason that the motor doesn't slow faster when you leave the pins open is because the resistance is too great, the power can't break through the air. To break through a dielectric (like air or plastic) you dont need amps, you need volts. In a motor there are lower voltages (as you pointed out 10 in my example) and much higher amperages. Rebuttal?
By your math i have a 10V motor, fine no problem. Still dissapates the 50W i said.
Your motor draws 10V at 5A. Its drawing 50W from the supply. Its resistance is NOT 2 Ohms. You actually don't know what its resistance is unless you measure it. For any decent motor R is usually pretty small. Try it.
what i am saying is that if you just open the terminals of the motor ( or short them with a resistor) all of the back EMF that is generated is only dissapated by the friction and internal coils in the motor. thats pretty much just coasting to a stop.
This is where you are wrong, and musunderstand the nature of the beast. SHORTING the terminals is exactly how it slows down fastest. You continue to confuse things like "Back EMF" and current in the motor, and have clearly not understood Lenz's law.
Please draw in detail where you believe a resistor should be connected in braking, and also what value it should be.
The resistor or short is only switched in during braking. Energy dissipation in the shorted motor is by the motors own winding resistance, since it is no longer a motor, but a generator, and the only source of energy for that generator is its own rotational inertia.
Look, Think about what happens if you apply the full motor voltage when the motor is at rest. The full voltage will appear across the armature resistance which will dissipate maximum power. As the motor torque accelerates the mechanical load, the motor speed, hence the back-emf, rises and the current, hence the power in the armature falls. Eventually, the back-emf is almost equal to the input voltage and the power dissipated by the armature reaches an idle level.
WHen running under load, I increases, as back emf decreases, and torque increases.
Now consider removing the input voltage and shorting the armature. The full back-emf (its a generator now)appears across the armature which dissipates almost as much as it did when starting. Eventually, the motor torque slows the mechanical load and eventually the motor stops.
So the armature power dissipation follows approximately the same curve against time when starting or stopping. So if your motor can survive having the full motor voltage applied from rest, it can survive having it's armature shorted at full speed.
In other words, what's the fastest way to dissipate the spinning energy in a generator ? Open circuit ? Load = infiinty, no energy is dissipated. Short circuit ? Power = V^2/r r= armature resistance, therefore Power is very very high. Or with an external load, R. Power = V^2/ (R+r) which is ALWAYS less than V^2/R
I suggest, instead of being wrong, you actually try it on a real PMDC motor, preferably a decent sized one, where brush frictional resistance becomes insignificant, and with a bit of flywheel on it for excitement. On a big motor, you can destroy it if you repeat short circuit braking, but one or two times it's OK.
Graph is of the relationship between speed and braking time for various external loads.
Also, bear in mind I've been designing motor control systems for 25 years.
So what i read from that is that while shorting your motor (and allowing however many up volts (in some cases up to thousands) to feed straight back into it is a bad idea. at least for the long term life of your motor.
You also depict with your graph that a resistance of 0, a short circuit DOES slow it the fastest. you also above point out that its bad for your motor. Your graph also depicts that the coasting , or "infinite" resistance of an open terminals does come to a stop slower.
My option that i provided with a resistor across the terminals not only would not damage the motor if it was used multiple times by limiting the current that can feed back in but also slows it quicker than coasting.
i fail to see how you prove me wrong in this case. I may not be intimately familiar with Lenz's law like you seem to be but everything your posting just supports what i said. All i know is that it is not good for a motor to be shorted across the terminals when its spinning.
The resistor or short is only switched in during braking. Energy dissipation in the shorted motor is by the motors own winding resistance, since it is no longer a motor, but a generator, and the only source of energy for that generator is its own rotational inertia.
By the way isn't this basically what i said with
"the resistor dissapates the power in the motor more quickly than the friction and the internal wiring would. "
By what i said you could infer that when the terminals are left open that it will merely coast to a stop and the if shorted then the friction (although it may be marginal) AND the internal wiring resistance would be feeding right back in and power would be generated by the motor continuing to turn.
The resistor or short is only switched in during braking.
"The catch is that the resistor should only be accross the terminals when the motor is not being powered."
I'm pretty sure you proved me right here again.
So what i read from that is that while shorting your motor (and allowing however many up volts (in some cases up to thousands) to feed straight back into it is a bad idea. at least for the long term life of your motor.
Once AGAIN you have your concepts completely muddled. ITS A SHORT CIRCUIT. Guess how many volts are across a SHORT CIRCUIT.
Yes, a transiently high CURRENT flows, and in BIG drives inertial constraints as well as electrical constraints means that braking resistors sometimes HAVE to be used to protect the mechanics as well as the electrics. FOR THE FASTEST PRACTICAL braking, we dump to a short. If you REALLY can afford to do it, there is actually one more stage faster, and that's called plugging the drive. In ultra high speed servos, you'll see plugging drives in action, they're scary.
By the way isn't this basically what i said with
"the resistor dissapates the power in the motor more quickly than the friction and the internal wiring would. "
No, because that's wrong. The internal wiring dissipates it faster than ANY EXTERNAL RESISTOR.
Just to summarize what I've been saying:
First we will assume the motor has been brought up to speed normally. No drives, just power that will take it up to full speed. Now we want to slow the motor back down. There are a couple options.
1. Open the contacts of the motor and leave them open while the friction in the motor (and the essentially infinite resistance) basically coast to a stop.
2. Use a resistor across the contacts. Limits the current flowing and prevents long term damage to the motor. Different values can slow at different rates: the lower the resistance the faster the slowing.
3. Short the contacts of the motor. Essentially you lowered the resistor across the contacts to zero, or near it. All of the current the motor can create (because its a generator now, as we have both pointed out) flows through the short (probably a relay) and through the motor. This can damage the motor over time, but does continue to slow the motor faster as the resistance lowers, like before. Not all motors are rated for this.
4.Apply some some amount of power to the motors contacts backwards. Called "Plugging". This tries to make the motor turn the opposite direction instantly. With a controlled bursts of this you can do this without hurting the motor. This is one of the basis' of DC and AC drives.
5. Load down the arm of the motor with a physical load too great to for the motor to turn.
Simple logic always says go to the far limits to test your principles, a open circuit will most certainly NOT effect your motor - this equates to an infinitely large resistor.
Any thing less than that will have a braking effect on the motor, the furthest you can go is to make it a short circuit for maximum braking.
For the most part in a system such as this the motor would be geared and so not require electrical braking as the gear system will mechanically stop the motor - unless the motor is a considerable size - unlikely.
I have built electric racing cars with 250 watt DC motors on them and can assure you that shorting the motor has a dramatic braking effect. Of course this effect falls away as the motor slows down.
Your putting way too much load on your microprocessor output, in practicality and for good design - you should always have a driver of some kind unless the load is trivial such as a small current LED.
This also isolates the microprocessor from the load and any misfortune that may happen there.
The diode needs to be reverse biased across the load- band towards the + supply. The diode is there to dissipate any back EMF generated by the collapsing magnetic field in a coil or the EMF generated by motor over run.
I hope this helps.
Has anyone figured out how to apply this to a car?