I need to mesure a door position & to control the door lock (too)

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:
  // 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,

Do I really need a relay?

No, a transistor or FET will work.

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.

I read http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads &

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.

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.

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.

the main problems were:

  • the single quote
  • the circuit to supply the door lock

thanks a lot, all works fine now :slight_smile:

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