Orodha ya maudhui:

Jinsi ya Kutengeneza Roboti mahiri Kutumia Arduino: Hatua 4
Jinsi ya Kutengeneza Roboti mahiri Kutumia Arduino: Hatua 4

Video: Jinsi ya Kutengeneza Roboti mahiri Kutumia Arduino: Hatua 4

Video: Jinsi ya Kutengeneza Roboti mahiri Kutumia Arduino: Hatua 4
Video: РАДУЖНЫЕ ДРУЗЬЯ — КАЧКИ?! НЕЗАКОННЫЕ Эксперименты VR! 2024, Novemba
Anonim
Image
Image

habari,

Mimi ni mtengenezaji wa arduino na katika mafunzo haya nitakuonyesha jinsi ya kutengeneza roboti mahiri kwa kutumia arduino

ikiwa ulipenda mafunzo yangu basi fikiria kuongezea kituo changu cha youtube kilichoitwa mtengenezaji wa arduino

Vifaa

MAMBO UTAKAYOHITAJI:

1) arduino uno

2) sensor ya ultrasonic

3) Bo motor

4) magurudumu

5) vijiti vya barafu

6) 9v betri

Hatua ya 1: Uunganisho

GONGA VIFAA VYOTE MAHALI
GONGA VIFAA VYOTE MAHALI

Baada ya kupata vifaa vyote sasa unapaswa kuanza kuunganisha vitu vyote kulingana na mchoro wa mzunguko uliopewa hapo juu

Hatua ya 2: PENDEKEZA VIFAA VYOTE KWA MAHALI

SAWA,

sasa unganisha vitu vyote mahali kama ilivyoonyeshwa kwenye picha hapo juu

Hatua ya 3: KUPANGA

Sasa,

anza kupanga bodi na nambari iliyopewa hapa chini

// Kizuizi cha ARDUINO KUEPUKA GARI //// Kabla ya kupakia nambari lazima usakinishe maktaba inayofaa // // Maktaba ya AFMotor https://learn.adafruit.com/adafruit-motor-shield/library-install // // Maktaba ya NewPing https://github.com/livetronic/Arduino-NewPing// // Servo Library https://github.com/arduino-libraries/Servo.git // // Kufunga maktaba nenda kwenye mchoro >> Jumuisha Maktaba >> Ongeza faili ya ZIP >> Chagua faili za ZIP zilizopakuliwa Kutoka kwa viungo hapo juu //

# pamoja

# pamoja

# pamoja

#fafanua TRIG_PIN A0

#fafanua ECHO_PIN A1 #fafanua MAX_DISTANCE 200

#fafanua MAX_SPEED 150 // inaweka kasi ya motors DC

#fafanua MAX_SPEED_OFFSET 20

SonP ya NewPing (TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

AF_DCMotor motor1 (1, MOTOR12_1KHZ);

// AF_DCMotor motor2 (2, MOTOR12_1KHZ); // AF_DCMotor motor3 (3, MOTOR34_1KHZ); AF_DCMotor motor4 (4, MOTOR34_1KHZ); Servo myservo;

boolean goesForward = uongo;

umbali int = 100; kasi ya intSet = 0;

usanidi batili () {

ambatisha. 10 (10);

andika (115); kuchelewesha (1000); umbali = kusomaPing (); kuchelewesha (100); umbali = kusomaPing (); kuchelewesha (100); umbali = kusomaPing (); kuchelewesha (100); umbali = kusomaPing (); kuchelewesha (100); }

kitanzi batili () {

umbali umbaliR = 0; umbali umbaliL = 0; kuchelewesha (40); ikiwa (umbali <= 15) {moveStop (); kuchelewesha (100); songaBackward (); kuchelewesha (300); hojaStop (); kuchelewesha (200); umbaliR = tazamaKulia (); kuchelewesha (300); umbaliL = tazamaLeft (); kuchelewesha (300);

ikiwa (umbaliR> = umbaliL)

{turnRight (); hojaStop (); } mwingine {turnLeft (); hojaStop (); }} mwingine {moveForward (); } umbali = kusomaPing (); }

kuangalia ndaniRight ()

{myservo.andika (50); kuchelewesha (650); umbali umbali = kusomaPing (); kuchelewesha (100); andika (115); umbali wa kurudi; }

kuangalia ndani kushoto ()

{myservo.write (170); kuchelewesha (650); umbali umbali = kusomaPing (); kuchelewesha (100); andika (115); umbali wa kurudi; kuchelewesha (100); }

kusoma kusoma () {

kuchelewesha (70); int cm = sonar.ping_cm (); ikiwa (cm == 0) {cm = 250; } kurudi cm; }

batili moveStop () {

motor1.unakimbia (KUACHIA); //motor2.run(RELEASE); //motor3.run(RELEASE); motor4.run (RELEASE); } batili songa mbele () {

ikiwa (! huenda mbele)

{goesForward = kweli; motor1.run (MBELE); //motor2.run(FORWARD); //motor3.run(FORWARD); motor4.run (MBELE); kwa (speedSet = 0; speedSet <MAX_SPEED; speedSet + = 2) // polepole kuleta kasi ili kuzuia kupakia betri haraka sana {motor1.setSpeed (speedSet); //motor2.setSpeed (SpeedSet); //motor3.setSpeed (SpeedSet); motor4.setSpeed (kasiSet); kuchelewesha (5); }}}

batili hojaBackward () {

goesForward = uongo; motor1.run (BACKWARD); //motor2.run(BACKWARD); //motor3.run(BACKWARD); motor4.run (BACKWARD); kwa (speedSet = 0; speedSet <MAX_SPEED; speedSet + = 2) // polepole kuleta kasi ili kuzuia kupakia betri haraka sana {motor1.setSpeed (speedSet); //motor2.setSpeed (SpeedSet); //motor3.setSpeed (SpeedSet); motor4.setSpeed (kasiSet); kuchelewesha (5); }}

TurnRight batili () {

motor1.run (BACKWARD); //motor2.run(BACKWARD); //motor3.run(FORWARD); motor4.run (MBELE); kuchelewesha (350); motor1.run (MBELE); //motor2.run(FORWARD); //motor3.run(FORWARD); motor4.run (MBELE); } batili turnLeft () {motor1.run (MBELE); //motor2.run(FORWARD); //motor3.run(BACKWARD); motor4.run (BACKWARD); kuchelewesha (350); motor1.run (MBELE); //motor2.run(FORWARD); //motor3.run(FORWARD); motor4.run (MBELE); }

Ilipendekeza: