how to solve the following program?

timer Asked: Nov 7th, 2016

Question description

Write a C++ class that models a toy motor in the following way:

  • Data — a pin used to connect to the motor
  • Actions:
    • creating the motor object, which takes a specific number for setting the pin
    • turning the motor on, which takes no input and gives no output
    • turning the motor off, which takes no input and gives no output
    • spinning the motor at a certain speed for a certain amount of time, which takes the speed and duration as input but gives no output

You are encouraged to add additional data and/or actions to your model of a toy motor. However, you must provide the behavior above as a minimum, and it must work correctly, before the course staff will consider additional behavior.

Put the declaration of your Motor class in a file called motor.h and the implementation of your Motor member functions in a file called motor.cpp.

Write an Arduino program called motor_demo.ino that creates one or more objects of your Motor class and uses the object(s) to demonstrate the full functionality of your class. To make the demo more fun and interesting, as well as making it easier for the course staff to observe the changing functionality, consider using the toy motor to move or spin a physical prop (such as a flag, pinwheel, toy wheel, fan blades).

NOTE: Do not include any libraries in any file of your project, other than “Arduino.h” and “motor.h”.

To facilitate demoing solutions to both parts of this assignment in the same session on Friday, November 11, make sure that you can wire your board with two servos and at least one toy motor.

Zip the Arduino folder that contains your motor_demo.ino, motor.h, motor.cpp files and submit the zip file. (The folder should not contain any other files.)

Tutor Answer

(Top Tutor) Studypool Tutor
School: Duke University
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors