41 lines
763 B
C++
41 lines
763 B
C++
int MODE = 8;
|
|
|
|
int left_motor_in = 6;
|
|
int left_motor_out = 9;
|
|
|
|
int right_motor_in = 3;
|
|
int right_motor_out = 5;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
Serial.println("Start");
|
|
init_motor();
|
|
}
|
|
|
|
void loop() {
|
|
left_motor_go(250);
|
|
right_motor_go(250);
|
|
}
|
|
|
|
void init_motor(){
|
|
pinMode(left_motor_in, OUTPUT);
|
|
pinMode(left_motor_out, OUTPUT);
|
|
|
|
pinMode(right_motor_in, OUTPUT);
|
|
pinMode(right_motor_out, OUTPUT);
|
|
|
|
pinMode(MODE, OUTPUT);
|
|
digitalWrite(MODE, HIGH);
|
|
}
|
|
|
|
//range:0<value<255
|
|
void left_motor_go(int motor_speed){
|
|
analogWrite(left_motor_in, motor_speed);
|
|
digitalWrite(left_motor_out, LOW);
|
|
}
|
|
//range:0<value<255
|
|
void right_motor_go(int motor_speed){
|
|
analogWrite(right_motor_in, motor_speed);
|
|
digitalWrite(right_motor_out, LOW);
|
|
}
|