Go Down

Topic: I need to mesure a door position & to control the door lock (too) (Read 471 times) previous topic - next topic

julienbayle

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: [Select]
  // 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,
Julien
http://julienbayle.net

Grumpy_Mike

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
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.

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.

julienbayle

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

thanks a lot, all works fine now :)

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

Julien
http://julienbayle.net

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy