Pages: [1]   Go Down
Author Topic: I need to mesure a door position & to control the door lock (too)  (Read 333 times)
0 Members and 1 Guest are viewing this topic.
France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
digital artist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hello,

I need to know if the door is open or not.
Easy with a button.

But at the same time, I need to control the door lock system.
It requires 12v and it only need a little current.
I only need to send 12v for 200ms, and the door lock opens itself.
This part work manually but I need to control it from an arduino via Max5

A guy told me to use a relay to supply the door lock with my
I thought I could use "only" a transistor BD135-like.

So here are my questions:
- I read http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads & other schemas, but I cannot find the right wiring for me.
could someone make it for me ?
- Do I really need a relay? or does this transistor could be enough?
- I would like to send a particular bytes ("o" for open..) from Max5 patch to Arduino and I'd like the arduino to compare the bytes received to a value constantly.
here is my sketch:
Code:
  // send data only when you receive data:
if (Serial.available() > 0) {
digitalWrite(doorlockPin, HIGH) ;
delay(1000);
digitalWrite(doorlockPin, LOW) ;
                        Serial.flush();
}
        else digitalWrite(doorlockPin, LOW) ;

The Serial.flush() is here because without it, the Serial.available is everytime >0 after the first byte sent.

I did that because Serial.read() results in a pointer and I cannot compare it...
Could someone help me with that ?


I'm finishing this last system for the museum I'm working with.
It would be so sweet to have some answers.

best,
Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do I really need a relay?
No, a transistor or FET will work.
Quote
and it only need a little current
The concept of "little" in not very accurate, I bet it needs a whole whack of current from the arduino perspective. You need to know how much.

Quote
My totally unfravroutiest web site, it tries but ultimately it is rubbish.
Look here:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html
for both relay drivers and direct transistors.

Quote
The Serial.flush() is here because without it, the Serial.available is everytime >0 after the first byte sent.

That is because you don't read anything.

Quote
I did that because Serial.read() results in a pointer
No it doesn't it is an ASCII character
val = Serial.read();
if(val == 'o') { digitalWrite(doorLockPin, HIGH); ........   
Note the single quote not a double one.
Logged

France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
digital artist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the main problems were:
- the single quote
- the circuit to supply the door lock

thanks a lot, all works fine now smiley

I'd probably explain all the project here or there, feel free to keep in touch on http://designthemedia.com

Logged


Pages: [1]   Go Up
Jump to: