Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I got this code with this ultrasonic sensor but it won't work properly can any one check this code? #define stop 0 #define forward 1

I got this code with this ultrasonic sensor but it won't work properly can any one check this code?
#define stop 0
#define forward 1
#define back 2
#define left 3
#define right 4
#define Trig A4
#define Echo A5
int MotSpeed1=0;
int MotSpeed2=0;
int Speed_adjustment =120;
int stop_bit=0;
void loop()
{
avoidance (18); }
void setup()
{
Serial.begin(9600);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (Trig, OUTPUT);
pinMode (Echo, INPUT);}
float GetDistance()
{
Float distance:
digitalWrite(Trig, LOW);
delayMicroseconds (2);
digitalWrite(Trig, HIGH);
delayMicroseconds (10);
digitalWrite(Trig, LOW):
Distance = pulseIn(Echo, HIGH)/58.00;
Return distance; }
Void motor1(int steep1, int steep2)
{
analogWrite(5, steep1):
analogWrite(6, steep2):
}
Void motor2(int steep1, int steep2)
{
analogWrite(9,steep1);
analogWrite(10, steep2);
}
void avoidance (int set_dis)
{
Void motor(int dir, int speed1, int speed2)

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago