|
1 | | -#include <DirectCurrent-Motor-Module.h> |
| 1 | +int engine1 = 12; |
| 2 | +int input_pin1 = 9; |
| 3 | +int input_pin2 = 8; |
| 4 | +int engine2 = 13; |
| 5 | +int input_pin3 = 10; |
| 6 | +int input_pin4 = 11; |
| 7 | + |
| 8 | +class DirectCurrent { |
| 9 | + public: |
| 10 | + int input1; |
| 11 | + int input2; |
| 12 | + int dc; |
| 13 | + void move(int mode1, int mode2, int speed) { |
| 14 | + digitalWrite(this->input1, mode1); |
| 15 | + digitalWrite(this->input2, mode2); |
| 16 | + analogWrite(this->dc, speed); |
| 17 | + } |
| 18 | +}; |
| 19 | + |
| 20 | +DirectCurrent motor1 = {9, 8, 12}; |
| 21 | +DirectCurrent motor2 = {10, 11, 13}; |
2 | 22 |
|
3 | 23 | void setup() { |
4 | | - DirectCurrent example = { 1, 2, 3 }; /* Setup an class object with INPUT1 pin = 1, INPUT2 pin = 2 and DC motor pin = 3 */ |
| 24 | + pinMode(engine1, OUTPUT); |
| 25 | + pinMode(engine2, OUTPUT); |
| 26 | + pinMode(input_pin1, OUTPUT); |
| 27 | + pinMode(input_pin2, OUTPUT); |
| 28 | + pinMode(input_pin3, OUTPUT); |
| 29 | + pinMode(input_pin4, OUTPUT); |
5 | 30 | } |
6 | 31 |
|
7 | 32 | void loop() { |
8 | | - example.move(example, 1, 0, 129); /* Move the DC motor with a speed of 129 by using the INPUT1 pin to set the motor rotating forward */ |
| 33 | + motor1.move(0, 0, 200); |
| 34 | + motor2.move(0, 0, 200); |
9 | 35 | } |
0 commit comments