This tutorial is part of: Hướng dẫn sử dụng bộ dụng cụ xe thông minh Elegoo
Các liên kết đến các video khác nằm bên dưới bài viết này.
Elegoo Robot Car Video #3: How to move forward, reverse and turn left and right
This tutorial is part of: Hướng dẫn sử dụng bộ dụng cụ xe thông minh Elegoo
264-Elegoo Smart Car Code: Left wheel rotation of the car
Ngôn ngữ: C++
// Provided by Robojax.com on Nov 25, 2019
// See video instructions for this video: https://youtu.be/JDgOYKo_zQ8
// www.elegoo.com
// Left motor truth table
// Here are some handy tables to show the various modes of operation.
// ENA IN1 IN2 Description
// LOW Not Applicable Not Applicable Motor is off
// HIGH LOW LOW Motor is stopped (brakes)
// HIGH HIGH LOW Motor is on and turning forwards
// HIGH LOW HIGH Motor is on and turning backwards
// HIGH HIGH HIGH Motor is stopped (brakes)
// define IO pin
#define ENA 5
#define IN1 7
#define IN2 8
// Initialize the car
void setup() {
pinMode(IN1, OUTPUT); // Set IO pin mode OUTPUT
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
digitalWrite(ENA, HIGH);// Enable left motor
}
// Main loop
void loop() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW); // Right wheel turning forwards
delay(500); // Delay 500ms
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW); // Right wheel stopped
delay(500);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);// Right wheel turning backwards
delay(500);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH); // Right wheel stopped
delay(500);
}
Tài nguyên & tài liệu tham khảo
Chưa có tài nguyên nào.
Tập tin📁
Không có tệp nào khả dụng.