hi, i am working on a project which has the output of DC motor. This dc motor is control by L293D chip in proteus. My input is two LDR sensor which is connected to arduino uno. Arduino is used to compare the voltage differences between both of the sensor. if there is a difference of voltage between both sensor, it will send HIGH signal to L293D input to rotate the motor. but now im facing a problem where my dc motor could not rotate in either direction. i have try many ways, but nothing happen to the motor. for the coding, the simulation in proteus show it follows the coding flow. but still the dc motor could not rotate. I hope you guys can help me. thanks.... [code] int sensorPinA0 = A0; // pin that the Bottom/Left sensor is attached to int sensorPinA1 = A1; // pin that the Right sensor is attached to const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A) const int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A) const int enablePin = 9; // H-bridge enable pin const int switchPin = 2; // variables: int sensorValueA0 = 0; // Bottom/Left photoresistor int sensorValueA1 = 0; // Right photoresistor void setup() { // Send debugging information via the Serial monitor Serial.begin(9600); analogReference(INTERNAL); //Assign and set motor driver pins to low pinMode(motor1Pin, OUTPUT); //digitalWrite(motor1Pin, LOW); pinMode(motor2Pin, OUTPUT); //digitalWrite(motor2Pin, LOW); pinMode(enablePin, OUTPUT); //digitalWrite(enablePin, HIGH); //pinMode(9, OUTPUT); pinMode(sensorValueA0, INPUT); pinMode(sensorValueA1, INPUT); pinMode(switchPin, INPUT); //digitalWrite(9, LOW); //pinMode(8, OUTPUT); //digitalWrite(8, LOW); } void loop() { // read the sensor: sensorValueA0 = analogRead(sensorPinA0); sensorValueA1 = analogRead(sensorPinA1); // if the switch is high, motor will turn on one direction: if (sensorValueA0 > sensorValueA1) { digitalWrite(switchPin, HIGH); // set the switch pin high digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high //digitalWrite(enablePin, HIGH); delay(100); } else { digitalWrite(switchPin, LOW); // set the switch pin high digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge high } if (sensorValueA0 < sensorValueA1) { digitalWrite(switchPin, HIGH); digitalWrite(motor1Pin, HIGH); digitalWrite(motor2Pin, LOW); //digitalWrite(enablePin, HIGH); } else { digitalWrite(switchPin, LOW); // set the switch pin high digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge high } //Print debugging information Serial.print("left reading = "); Serial.println(sensorValueA0); // the left/bottom sensor analog reading Serial.print("right reading = "); Serial.println(sensorValueA1); // the right sensor analog reading //Serial.print("Top reading = "); //Serial.println(sensorValueA2); // the top sensor analog reading delay(1000); } [/code]


JLCPCB – Prototype 10 PCBs for $2 (For Any Color)

China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir