Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to reduce the speed in this code ( I have 3 wheels motor, and 2 motor driver ) arduino mega code : int

I need to reduce the speed in this code ( I have 3 wheels motor, and 2 motor driver ) arduino mega code :

int x=10; int E1 = 4; int E2 = 5; int M1 = 6; int M2 = 7; int E3 = 8; int E4 = 9; int M3 = 10; int M4 = 11; void stop(void) { digitalWrite(E1,0); digitalWrite(M1,LOW); digitalWrite(E2,0); digitalWrite(M2,LOW); digitalWrite(E3,0); digitalWrite(M3,LOW); digitalWrite(E4,0); digitalWrite(M4,LOW); } void forward(char a,char b,char c) { //PWM Speed Control analogWrite (E2,a); digitalWrite(M2,HIGH); digitalWrite(E3,b); digitalWrite(M3,HIGH); digitalWrite(E4,c); digitalWrite(M4,HIGH); } void reverse(char a,char b,char c) //Move backward { analogWrite (E2,a); digitalWrite(M2,LOW); digitalWrite(E3,b); digitalWrite(M3,LOW); digitalWrite(E4,c); digitalWrite(M4,LOW); } void left(char a,char b,char c) //Turn Left { analogWrite (E2,a); digitalWrite(M2,HIGH); digitalWrite(E3,b); digitalWrite(M3,LOW); digitalWrite(E4,c); digitalWrite(M4,HIGH); } void right(char a,char b,char c) //Turn Right { analogWrite (E2,a); digitalWrite(M2,LOW); digitalWrite(E3,b); digitalWrite(M3,HIGH); digitalWrite(E4,c); digitalWrite(M4,LOW); } void setup(void) { Serial.begin(9600); //Set Baud Rate digitalWrite(E1,LOW); digitalWrite(E2,LOW); digitalWrite(E3,LOW); digitalWrite(E4,LOW); digitalWrite(M1,0); digitalWrite(M2,0); digitalWrite(M3,0); digitalWrite(M4,0); } void loop(void) { while(x>1) { forward(55,55,55); delay(3000); /* left(10,10,10); delay(2500); forward(55,55,55); delay(3000); right(10,10,10); delay(2500); forward(55,55,55); delay(3000); stop(); reverse(55,55,55); delay(3000);*/ stop(); x=0; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions