Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the following the questions based on the code snippet below: void loop ( ) { / / Set motor A speed and direction analogWrite

Answer the following the questions based on the code snippet below:
void loop(){
// Set motor A speed and direction
analogWrite (enA,150); // Speed control (0-255)
digitalWrite (inl, HIGH) ;
digitalWrite (in2, LOW) ;
// Set motor B speed and direction
analogWrite (enB,150); // Speed control (0-255)
digitalWrite (in3, HIGH) ;
digitalWrite (in4, LOW) ;
}
a) Create a variable called motorSpeed that will store the speed of the dc motors. Rewrite the code above so that the variable is substituted for the value 150 and the motors are spinning in the opposite directions.
b) Create a second variable motorSpeed2. Using motorSpeed and motorSpeed2, modify the code so that the motor B spinning at twice the speed of motor A in the same direction.
image text in transcribed

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions