Muhammad_Munir
Published © GPL3+

Control Motor with Touch Sensors

How to Control DC Motor with Touch Sensors

BeginnerFull instructions provided597
Control Motor with Touch Sensors

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Touch Sensor
×1
Jumper wires
×1
Motor Driver
×1
Bread Board
×1
Dc Motor
×1
Battery Holder
×1
Batteries
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Diagram

Code

Code

Arduino
// set pin numbers:
const int btn_Clock_wise = 3;
const int btn_Anti_Clock_wise = 5;
const int btn_Stop = 4;
const int IN1 =  A0;
const int IN2 = A1;


void setup() {
  Serial.begin(9600);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(btn_Clock_wise, INPUT);
  pinMode(btn_Anti_Clock_wise, INPUT);
  pinMode(btn_Stop, INPUT);
  
}

void loop() {

  if (digitalRead(btn_Clock_wise) == HIGH) {
    digitalWrite(IN2, HIGH);
    delay (500);
    digitalWrite(IN1, LOW);
    Serial.println("Rotate motor anti-Clock wise");
    delay (500);
  }
  else if (digitalRead(btn_Anti_Clock_wise) == HIGH) {
    digitalWrite(IN1, HIGH);
    delay (500);
    digitalWrite(IN2, LOW);
    Serial.println("Rotate motor Clock wise");
    delay (500);
  }
    else if (digitalRead(btn_Stop) == HIGH) {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, HIGH);
    Serial.println("Stop the motor");
    delay (500);
  }
}

Credits

Muhammad_Munir
79 projects • 56 followers
I am Arduino programmer, also expertise in ESP32 and 8266 wifi modules.

Comments