/*
#include <SmartInventor.h>
*/
void setup() {
SmartInventor.DCMotor();
}
void loop() {
// M1, M2, M3
// CW, CCW, STOP
// 0-100
// 0-360
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(5000);
SmartInventor.DCMotor(M1, CCW, 10, 45°); //Music starts //0:00:06
delay(2000);
SmartInventor.DCMotor(M1, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(11000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°); //Music stops //0:00:32
delay(10000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(5000);
SmartInventor.DCMotor(M1, CCW, 10, 45°);
delay(1000);
SmartInventor.DCMotor(M1, CW, 10, 45°); //Music starts back up //0:00:44
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(18000);
SmartInventor.DCMotor(M1, CCW, 10, 90°);
delay(3000);
SmartInventor.DCMOtor(M1, CW, 10, 45°);
delay(2000);
SmartINventor.DCMotor(M1, STOP, 10, 0°);
delay(8000);
SmartInventor.DCMOtor(M1, CW, 10, 45°); //Music stops //0:01:15
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(5000);
SmartINventor.DCMotor(M1, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(3000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°); //Music starts up agian //0:01:31
delay(11000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°); //Music stops //0:02:03
delay(23000);
SmartInventor.DCMotor(M1, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°); //Music starts up agian //0:02:14
delay(12000);
SmartInventor.DCMotor(M1, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(6000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(6000);
SmartInventor.DCMotor(M1, CCW, 10, 45°); //Music Ends //0:02:40
delay(2000);
SmartInventor.DCMotor(M1, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M1, STOP, 0, 0°);
delay(3000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(5000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000)
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(13000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(13000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(13000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000)
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventer.DCMotor(M2, CCW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(2000);
SmartInventor.DCMotor(M2, CW, 10, 45°);
delay(2000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(7000);
SmartInventor.DCMotor(M3, STOP, 0, 0°);
delay(7000);
SmartInventor.DCMotor(M3, CW, 20, 360°);
delay(26000);
SmartInventor.DCMotor(M3, STOP, 0, 0°);
delay(12000);
SmartInventor.DCMotor(M3, CW, 20, 360°);
delay(31000);
SmartInventor.DCMotor(M3, STOP, 0, 0°);
delay(12000);
SmartInventor.DCMotor(M3, CW, 20, 360°);
delay(31000);
SmartInventor.DCMotor(M3, STOP, 0, 0°);
delay(12000);
SmartInventor.DCMotor(M3, CW, 20, 360°);
delay(26000);
SmartInventor.DCMotor(M2, STOP, 0, 0°);
delay(5000);
< SmartInventor.h / >
}
You code shows multiple errors:
At the start you are commenting the
SmartInventor
library out. You need this library. You should delete the comment markers/*
and*/
around the#include
statement.At the end of the code you have
< SmartInventor.h / >
. You should delete this line. It is simply wrong, not even C/C++ syntax.You seem to misunderstand, what
SmartInventor.DCMotor()
is and does. First this is a DC motor. That means, that you don't have control over the angle of the motor. You can give it a direction and a speed. Nothing more. And with a standard DC motor (without gears) you cannot even hope for getting specific angles from it, not even through sophisticated controls. The motor is simply not made for such tasks.When you look into
SmartInventor.h
, you can see the declaration of that function:void SmartInventorClass::DCMotor(char SelectMotor, char direction, char speed)
You have too many parameters there. You can give this function 2 or 3 parameters (the 2 parameter prototype is not shown here, you can see it in the header file). Use the function as described.
Connected to the previous problem: You tried to use the
°
degree character in your code. You cannot do that. It is not a valid character in the C/C++ syntax. In general all the numbers in a program don't have a unit attached to them. You don't writedelay(1000ms)
to delay 1s, you writedelay(1000)
. It is up to the function, to interpret this number, as it likes to. You only know from the documentation of that function (or from it's implementation in code), that the parameters means time in milliseconds. For the microcontroller the unit millisecond does not have a meaning. The same goes with degree. When controlling a servo, which you can give the desired angle, you writeservo.write(90)
for setting it to 90°. No degree sign there.
-
So I use delay(1000) for mine? and what do you mean by too much parameters? – Tommy Mar 19 '20 at 23:21
-
You are using
DCMotor(M1, STOP, 0, 0°)
. That are 4 parameters for the function. But the function has only 2 or 3 parameters. You cannot provide more parameters. – chrisl Mar 19 '20 at 23:26 -
The
delay()
function was used correctly by you. I just used this function to explain, that the microcontroller does not know about units. – chrisl Mar 19 '20 at 23:26 -
Ok I just deleted ° and i did everything u told me to do but now it says no matching function call to 'SmartInentor::DCMotor()' – Tommy Mar 19 '20 at 23:49
-
1The full error message. The compiler gives you a rather extensive explanation, what is wrong where. You didn't include the full error message the first time, so please at least do it now. I don't like to guess, what exactly the error is. – chrisl Mar 20 '20 at 0:10
< SmartInventor.h / >
at the end of the program? That looks somewhat like a XML/HTML tag – chrisl Mar 19 '20 at 20:25°
characters from the code – chrisl Mar 19 '20 at 20:59