0

I want to use L298N bridge to power up and control simple smart lock. It requires 12V power supply, so I've used L298N bridge to power this smart lock.

I removed jumper from enA pin and connected enA 12V to Arduino Nano D8 pin.

I sent value 255 through this pin but smart lock did nothing. Any suggestions?

I'm using BLE controller to send turn on/off signal from Android App (but its not relevant in this case, because analogWrite is called).

Lock: https://www.aliexpress.com/item/32949292074.html

Here is code:

#define enA 8

void setup() {
  pinMode(enA, OUTPUT);
}

void loop() {
 String msg = bluetooth.read(); //using BLE controller to get message from Android app.

 if(msg == "ON"){
   analogWrite(enA, 255);
 } else if(msg == "OFF"){
   analogWrite(enA, 0);
 }

}

Here is setup:

enter image description here

5
  • majenko.co.uk/blog/importance-sharing-grounds
    – Majenko
    Commented Apr 23, 2020 at 15:14
  • Also: you need to control the direction pins or it won't know what to do.
    – Majenko
    Commented Apr 23, 2020 at 15:14
  • So I have to ground everything including BLE controller through breadboard like this? i.imgur.com/ZueUc82.png (and I'm powering Arduino through USB port)
    – Martin
    Commented Apr 23, 2020 at 15:39
  • that item from aliexpress is not a smart lock ... it is a solenoid
    – jsotola
    Commented Apr 23, 2020 at 16:34
  • It looks to me like you failed to tie the grounds of the Arduino and the H-Bridge together.
    – Duncan C
    Commented Apr 23, 2020 at 17:33

1 Answer 1

0

You really don't want an L239D to control that lock. It's overkill. The L239D is a H-bridge that is designed to drive loads in two different polarities (forward / backwards on a motor for example).

That lock is merely a spring-loaded solenoid. You give it power and it pulls the lock back. You remove power and the spring closes it again.

All you need is a simple transistor circuit just like you'd use for a relay.


Since you insist on using an L239D, here's a schematic for you:

schematic

simulate this circuit – Schematic created using CircuitLab

6
  • I understand that but I dont have time to buy transistor and everything is delayed due to corona. I know that its overkill :D Also I have to apply power to IN1 pin too? IN1 ---- D9 and digitalWrite(9, HIGH); ?
    – Martin
    Commented Apr 23, 2020 at 15:51
  • And IN2, which has to be the opposite level to IN1. IN1 and IN2 define the direction of current flow through the load. EN1 defines the level of current through the load.
    – Majenko
    Commented Apr 23, 2020 at 15:53
  • Ive tried to connect ground pins through breadboard but now L298N is not powered for some reason. Before red LED turn on as I powered adapter. Isnt Arduino powered by USB from laptop a reason?
    – Martin
    Commented Apr 23, 2020 at 16:23
  • 1
    Don't forget the L239D's ground needs connecting.
    – Majenko
    Commented Apr 23, 2020 at 16:24
  • Ahh so i.imgur.com/ZueUc82.png L239D ground can go to minus pins or straight to the top GND pin in Arduino
    – Martin
    Commented Apr 23, 2020 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.