Hi i am Working on a project to control multiple door locks using arduino Due ... and i am stuck in between circuit ... with the help of code i can control my LEDS ( one pin to ground other to digital output ) but when i use NPN transistor to control it i am not able to do it so. Following describe my connection....
12-16V , 2-2.5amp(its written 12v and 1 amp but Meter shows high value) DC Supply -------> + Of Lock.
TIP 122 Base -------> Pin 6 of arduino due (270 ohms Resistor and tried 10k,20k and without).
TIP 122 Collector ------> Lock - and to Arduino due ground.
TIP 122 Emiter ------> DC power source Ground.
Now When I connect All The Lock is locked, and i try to use Serial Monitor to get it disconnected, nothing happens, If i test it using my LED one to Arduino ground and other to pin 6 it turns off and on... but when i do it with above circuit it does not work. if i disconnect base from arduino lock is unlocked, and even if i connect it to analog or even ground pin it get connected/locked. i checked using multimeter Arduino pin gives 0 amp output on LOW........
So what i am doing wrong ?
Please describe in detail i am not electronic student ..and its my first hardware project ever!
For Understanding my arduino Code:
char val;
char val2;
char val3;// variable to receive data from the serial port
int lock = 6; // LED connected to pin 2 (on-board LED)
int unlock = 7;
int lock2 = 8;
int unlock2 = 9;
int lock3 = 10;
int unlock3 = 11;void setup()
{
pinMode(lock, OUTPUT); // pin 6 (on-board LED) as OUTPUT
pinMode(unlock, OUTPUT); // pin 7 (on-board LED) as OUTPUT
pinMode(lock2, OUTPUT); // pin 8 (on-board LED) as OUTPUT
pinMode(unlock2, OUTPUT); // pin 9 (on-board LED) as OUTPUT
pinMode(lock3, OUTPUT); // pin 10 (on-board LED) as OUTPUT
pinMode(unlock3, OUTPUT); // pin 11 (on-board LED) as OUTPUTSerial.begin(9600); // start serial communication at 9600bps
Serial2.begin(9600);
Serial3.begin(9600);digitalWrite(lock,HIGH);
digitalWrite(unlock,LOW);digitalWrite(lock2,HIGH);
digitalWrite(unlock2,LOW);digitalWrite(lock3,HIGH);
digitalWrite(unlock3,LOW);}
void loop() {
if( Serial.available() ) // if data is available to read
{;}
if(Serial2.available())
{;}
if(Serial3.available())
{;}val = Serial.read(); // read it and store it in 'val'
val2 = Serial2.read();
val3 = Serial3.read();if(val == 'A' || val2 == 'A' || val3 =='A'){
Serial.write("Door One Unlocked");
digitalWrite(lock,LOW);
digitalWrite(unlock,HIGH);
delay(5000);
Serial.write("Door One Locked");
digitalWrite(lock,HIGH);
digitalWrite(unlock,LOW);
}if(val == 'B' || val2 == 'B' || val3 =='B'){
Serial.write("Door Two Unlocked");
digitalWrite(lock2,LOW);
digitalWrite(unlock2,HIGH);
delay(5000);
Serial.write("Door Two Locked");
digitalWrite(lock2,HIGH);
digitalWrite(unlock2,LOW);}
if(val == 'C' || val2 == 'C' || val3 =='C'){
Serial.write("Door Three Unlocked");digitalWrite(lock3,LOW);
digitalWrite(unlock3,HIGH);
delay(5000);
Serial.write("Door Three Locked");
digitalWrite(lock3,HIGH);
digitalWrite(unlock3,LOW);
}}