Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
controlling DC motor with Keypad
Author Summary
ArmanXZS is in District of Columbia
Post Body

Hi, I'm new with arduino and coding , so I was trying to control a Dc motor'sspeed and direction with keypad on proteus!but when i run it , it's not warking , pins low and high change but dc motor direction is not changing!

is it something wrong with my wiring or coding! does any one know how can i fix it?

#include <Keypad.h>

//Pins of L298
int in1 = A0; //Declaring where our module is wired
int in2 = A1;
int ConA = 3;
int Mspeed = 150;


const byte ROWS = 4; //4 rows
const byte COLS = 4; //4 columns
char keys[ROWS][COLS] = {
  {'7', '8', '9', '/'},
  {'4', '5', '6', '*'},
  {'1', '2', '3', '-'},
  {'C', '0', '=', ' '}
};
byte rowPins[ROWS] = {11, 10, 9, 8};  //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4};  //connect to the column pinouts of the keypad

Keypad key = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


void setup() {
Serial.begin(9600);
pinMode(ConA, OUTPUT);  
pinMode(in1, OUTPUT); // declare as output for L298 Pin in1 
pinMode(in2, OUTPUT); // declare as output for L298 Pin in2 
analogWrite(ConA, Mspeed); 
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
delay(200);
}


void TurnMotorA(){
analogWrite(ConA,Mspeed);
char keys = key.getKey();


if (keys != NO_KEY){
  if (keys == '2'){
    if(Mspeed <= 255){
      Mspeed  ;}}


  if (keys == '8'){
    if(Mspeed >= 5){
      Mspeed--;}}

  if (keys == '4'){
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
  }

  if (keys == '6'){
    digitalWrite(in1,LOW);
    digitalWrite(in2,HIGH);
  }

  if (keys == '5'){
    digitalWrite(in1,HIGH);
    digitalWrite(in2,HIGH);
  }

Mspeed = analogRead(keys);
delay(50);
}

}

void loop() {
TurnMotorA();
}

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
37,332
Link Karma
18,374
Comment Karma
17,571
Profile updated: 3 days ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago