Write a C++ class that models a toy motor in the following way:
- Data — a pin used to connect to the motor
- 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.)