За ойрд хичээл оруулсангүй sorry guys! Энэхүү хичээлийг оруулахдаа PaulMakesThings ээс санаа авсан болно.
Arduino nano 1ш
3.7v Lipo баттерей 1 ш
Жижиг серво мотор 2 ш
Ремен
40 пин хөл эр эм
Микро серво моторыг тасралтгүй эргэлттэй болгох нь энэхүү микроботыг хийхэд хамгийн чухал алхам юм. Интернетэд серво моторыг тасралтгүй эргэлттэй болгох олон арга байдаг та аль ч аргыг нь ашиглаж болно. Жишээ нь доорхи арга
Дриллээр сервоны хайрцагыг цоолон дамарыг тогтооно. Энэ үед танд халуун буун цавуу хэрэг болно
D10, D11 ээр портоор серво моторыг удирдана.
та дээрхи зурагт харуулсанчлан өөрийн хүссэн загвараар угсарч болно. Учир та бол зохион бүтээгч :)
//---------------------------Start Code
#include <Servo.h>//Loads commands to create Servo objects which generate PWM signals
Servo leftDrive; // create servo object to control a servo
Servo rightDrive; //another servo object for the left side
void setup()
{
leftDrive.attach(11); // attaches the servo on pin 9 to the servo object
rightDrive.attach(10); // attaches the servo on pin 9 to the servo object
}
void loop()
{
//here put commands which drive the servos
//use the commands
//rightDrive.write(any number 0-180);
//leftDrive.write(any number 0 to 180);
//to set the servos turning 0 is full one way, 180 is full the other, 90 should be near stop
//which way is forward depends on your servos
}
//end code -------------------------------------
So that gives you an idea how simple this can be.
Here is a basic code example for just driving around in a square. Note that the video was with the delays set to 600, which resulted in a triangle, 450 gives you more of a square. (code starts after this line):
//------------------------------------------------------------------------------------------
#include <Servo.h>//Loads commands to create Servo objects which generate PWM signals
Servo leftDrive; // create servo object to control a servo
Servo rightDrive; //another servo object for the left side
int pos = 0; // variable to store the servo position
void setup()
{
leftDrive.attach(11); // attaches the servo on pin 9 to the servo object
rightDrive.attach(10); // attaches the servo on pin 9 to the servo object
}
void loop()
{
//example routine, drives in a square
turnRight();
driveForward();
turnRight();
driveForward();
turnRight();
driveForward();
turnRight();
driveForward();
}
//the following functions are examples, you could easily make the robot
//move on curved paths or at varying speeds by changing these numbers
//0 is full forward, 90 is stop and 180 is full reverse. The case may be the
//opposite for your build
//turns right about 90 degrees
void turnRight()
{
leftDrive.write(0);
rightDrive.write(180);
delay(450);
}
//turns left about 90 degrees
void turnLeft()
{
leftDrive.write(180);
rightDrive.write(0);
delay(450);
}
//drives straight for 1 second
void driveForward()
{
leftDrive.write(180);
rightDrive.write(180);
delay(1000);
}
//drives straight backward for 1 second
void driveBackward()
{
leftDrive.write(0);
rightDrive.write(0);
delay(1000);
}
//end code---------------------------------------------
Сагсанд амжилттай орлоо