Day 7- Moter Driver with Ardino

 Day 7- Moter Driver with Arduino

Task

1) Pin out L293

2) Pinout L298

3) Connection L293 with moter and battery

4) RF remote control Car

5) IR remote control Car

6) moter Speed Control using L293 moter driver ic

7) Remote control DC fan

8) Remote control Curtain



L293D Moter Driver H bridge IC


L293D Moter Driver H bridge IC



L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors.


L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation, two DC motors can be driven simultaneously, both in forward and reverse direction. The motor operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and anticlockwise directions, respectively.

Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start operating. When an enable input is high, the associated driver gets enabled. As a result, the outputs become active and work in phase with their inputs. Similarly, when the enable input is low, that driver is disabled, and their outputs are off and in the high-impedance state.


Circuit Diagram
https://electronics4ubymanmohanpal.blogspot.com/p/l293-d.html


Manmohan Pal
Mob. 8989811397
Email- mannmohanpal@gmail.com
Blog: http://electronics4ubymanmohanpal.blogspot.in/p/blog-page_5.html
Youtube Channel: https://www.youtube.com/channel/UCDnhARnHOEIPuNIEp5vPdGQ



Pin No
 Function
 Name
1
Enable pin for Motor 1; active high
Enable 1,2
2
Input 1 for Motor 1
Input 1
3
Output 1 for Motor 1
Output 1
4
Ground (0V)
Ground
5
Ground (0V)
Ground
6
Output 2 for Motor 1
Output 2
7
Input 2 for Motor 1
Input 2
8
Supply voltage for Motors; 9-12V (up to 36V)
 Vcc 2
9
Enable pin for Motor 2; active high
Enable 3,4
10
Input 1 for Motor 2
Input 3
11
Output 1 for Motor 2
Output 3
12
Ground (0V)
Ground
13
Ground (0V)
Ground
14
Output 2 for Motor 2
Output 4
15
Input2 for Motor 2
Input 4
16
Supply voltage; 5V (up to 36V)
Vcc 1

















------------------------------------------------------------------------------------

Code to control 4 Relays, IR Remote, 4 Debounce btn, 2 Moters for Curtain


circuit to connect moter driver with IR Remote Arduino




#include <IRremote.h>

int RECV_PIN = 11 ;

IRrecv irrecv(RECV_PIN);

decode_results results;

unsigned long key_value = 0;

unsigned long previousMillis = 0;  
const long interval = 200;  

const int Relay1=2;
const int Relay2=3;
const int Relay3=4;
const int Relay4=5;

const int MoterA1=6;
const int MoterA2=7;
const int MoterB1=8;
const int MoterB2=9;

byte Relay1state=0;
byte Relay2state=0;
byte Relay3state=0;
byte Relay4state=0;

const int button1Pin = 14;  
const int button2Pin = 15;
const int button3Pin = 16;  
const int button4Pin = 17;

int button1State;
int button2State;  
int button3State;  
int button4State;  

int lastButton1State = LOW;
int lastButton2State = LOW;
int lastButton3State = LOW;
int lastButton4State = LOW;

unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;

void setup(){
  Serial.begin(9600);

  irrecv.enableIRIn();
  irrecv.blink13(true);

 pinMode(Relay1,OUTPUT);
 pinMode(Relay2,OUTPUT);
 pinMode(Relay3,OUTPUT);
 pinMode(Relay4,OUTPUT);

digitalWrite(Relay1,LOW);
digitalWrite(Relay2,LOW);
digitalWrite(Relay3,LOW);
digitalWrite(Relay4,LOW);

 pinMode(MoterA1,OUTPUT);
 pinMode(MoterA2,OUTPUT);
 pinMode(MoterB1,OUTPUT);
 pinMode(MoterB2,OUTPUT);

  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);
  pinMode(button3Pin, INPUT);
  pinMode(button4Pin, INPUT);

  digitalWrite(MoterA1,LOW);
  digitalWrite(MoterA2,LOW);
  digitalWrite(MoterB1,LOW);
  digitalWrite(MoterB2,LOW);

  digitalWrite(button1Pin,HIGH);
  digitalWrite(button2Pin,HIGH);
  digitalWrite(button3Pin,HIGH);
  digitalWrite(button4Pin,HIGH);

  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
  delay(1000);
 
  Serial.println("ready to accepte IR Remote input ");
}

void loop(){

  unsigned long currentMillis = millis();

  if (irrecv.decode(&results)){

    Serial.println(results.value, HEX);
    Serial.println(results.value, DEC);

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){
          case 0xFFC03F:
          Serial.println("Mute");
          break;

          case 0xFF906F:
          Serial.println("PWR");
          break;

          case 0xFFB04F:
          Serial.println("1");
          Relay1state=!Relay1state;
          digitalWrite(Relay1,Relay1state);
           delay(300);
          break;

          case 0xFF9867:
          Serial.println("2");
          Relay2state=!Relay2state;
          digitalWrite(Relay2,Relay2state);
           delay(300);
          break;

          case 0xFFD827:
          Serial.println("3");
          Relay3state=!Relay3state;
           digitalWrite(Relay3,Relay3state);
           delay(300);
          break;

          case 0xFF807F:
          Serial.println("4");
          Relay4state=!Relay4state;
          digitalWrite(Relay4,Relay4state);
           delay(300);
          break;

          case 0xFF8877:
          Serial.println("5");
         
          break;

          case 0xFFA857:
          Serial.println("6");
         
          break;

          case 0xFFE817:
          Serial.println("7");
         
          break;

          case 0xFF609F:
          Serial.println("8");
          break;

          case 0xFF48B7:
          Serial.println("9");
          break;

          case 0xFF6897:
          Serial.println("0");
          break;

          case 0xFF708F:
          Serial.println("UP");

          digitalWrite(MoterA1,HIGH);
          digitalWrite(MoterA2,LOW);

          break;

          case 0xFF58A7:
          Serial.println("Down");

          digitalWrite(MoterA1,LOW);
          digitalWrite(MoterA2,HIGH);

         
          break;

          case 0xFF50AF:
          Serial.println("Left");

          digitalWrite(MoterB1,HIGH);
          digitalWrite(MoterB2,LOW);
         
          break;

          case 0xFF7887:
          Serial.println("Right");

          digitalWrite(MoterB1,LOW);
          digitalWrite(MoterB2,HIGH);
         
          break;

           case 0xFFA05F:
          Serial.println("OK");

          digitalWrite(MoterA1,LOW);
          digitalWrite(MoterA2,LOW);
          digitalWrite(MoterB1,LOW);
          digitalWrite(MoterB2,LOW);
         
          break;
        }
        key_value = results.value;
        previousMillis = currentMillis;
        irrecv.resume();  
  }

  else {
    if (currentMillis - previousMillis >= interval) {
    digitalWrite(MoterA1,LOW);
    digitalWrite(MoterA2,LOW);
    digitalWrite(MoterB1,LOW);
    digitalWrite(MoterB2,LOW);
  }
  }
///////////////////////////////////////////////////////////
  int reading1 = digitalRead(button1Pin);
  int reading2 = digitalRead(button2Pin);
  int reading3 = digitalRead(button3Pin);
  int reading4 = digitalRead(button4Pin);
   
  if (reading1 != lastButton1State) {
    lastDebounceTime = millis(); }

  if (reading2 != lastButton2State) {
    lastDebounceTime = millis(); }

  if (reading3 != lastButton3State) {
    lastDebounceTime = millis(); }

  if (reading4 != lastButton4State) {
    lastDebounceTime = millis(); }

    //////////////////////////////////////////////////////

  if ((millis() - lastDebounceTime) > debounceDelay) {
     if (reading1 != button1State) {
      button1State = reading1;
      if (button1State == HIGH) {
        Relay1state = !Relay1state;
       
      }}}

 if ((millis() - lastDebounceTime) > debounceDelay) {
     if (reading2 != button2State) {
      button2State = reading2;
      if (button2State == HIGH) {
        Relay2state = !Relay2state;
       
      }}}

  if ((millis() - lastDebounceTime) > debounceDelay) {
     if (reading3 != button3State) {
      button3State = reading3;
      if (button3State == HIGH) {
        Relay3state = !Relay3state;
       
      }}}

  if ((millis() - lastDebounceTime) > debounceDelay) {
     if (reading4 != button4State) {
      button4State = reading4;
      if (button4State == HIGH) {
        Relay4state = !Relay4state;
       
      }}}
////////////////////////////////////////////////////////

digitalWrite(Relay1,Relay1state);
digitalWrite(Relay2,Relay2state);
digitalWrite(Relay3,Relay3state);
digitalWrite(Relay4,Relay4state);
 
   lastButton1State = reading1;
   lastButton2State = reading2;
   lastButton3State = reading3;
   lastButton4State = reading4;

  }

------------------------------------------------------------------------------------

No comments:

Post a Comment

Arduion Uno pin out