Zbekiston respublikasi oliy va o‘rta maxsus ta’lim vazirligi farg‘ona davlat universiteti fizika texnika fakulteti
Download 455.21 Kb.
|
Sobirova2013
5-qadam: Ikki dvigatel
Ikki dvigatel bilan o'zaro bog'lanish deyarli bitta dvigatel bilan interfeysga o'xshaydi. Dvigatelni B kanaliga ulash kifoya. Kod bo'yicha yagona farq shundaki, siz ikkinchi dvigatelni boshqarish uchun ikkinchi kanalni ulashingiz kerak. Mana ikkita motorni boshqarish uchun kod: /**************************************************** **************** Dvigatel shieldi 2-kanalli DC motor namoyishi Rendi Sarafan tomonidan Qo'shimcha ma'lumot olish uchun qarang: https://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/ ***************************************************** ************/ void setup() { //A kanalini sozlash pinMode (12, OUTPUT); //A motor kanalining pinini ishga tushiradi pinMode (9, OUTPUT); // Tormoz kanali A pinini ishga tushiradi // B kanalini sozlash pinMode (13, OUTPUT); //A motor kanalining pinini ishga tushiradi pinMode (8, OUTPUT); // Tormoz kanali A pinini ishga tushiradi } void loop(){ //Motor A oldinga @ to'liq tezlikda digitalWrite (12, HIGHT); //A kanalining oldinga yo'nalishini o'rnatadi digitalWrite (9, LOW); // A kanali uchun tormozni o'chiring analogWrite(3, 255); //Dvigatelni A kanalida to'liq tezlikda aylantiradi //Dvigatel B orqaga @ yarim tezlikda digitalWrite (13, LOW); //B kanalining orqaga yo'nalishini o'rnatadi digitalWrite (8, LOW); // Kanal B uchun tormozni o'chiring analogWrite(11, 123); //Dvigatelni B kanalida yarim tezlikda aylantiradi delay(3000); digitalWrite(9, HIGHT); //A kanali uchun tormozni yoqing digitalWrite(9, HIGHT); //Kanal B uchun tormozni yoqing delay (1000); //Motor A oldinga @ to'liq tezlikda digitalWrite (12, LOW); //A kanalining orqaga yo'nalishini o'rnatadi digitalWrite (9, LOW); // A kanali uchun tormozni o'chiring analogWrite(3, 123); //Dvigatelni A kanalida yarim tezlikda aylantiradi //Dvigatel B oldinga @ to'liq tezlikda digitalWrite(13, HIGHT); //B kanalining oldinga yo'nalishini o'rnatadi digitalWrite (8, LOW); // Kanal B uchun tormozni o'chiring analogWrite(11, 255); //Dvigatelni B kanalida to'liq tezlikda aylantiradi delay (3000); digitalWrite(9, HIGHT); //A kanali uchun tormozni yoqing digitalWrite(9, HIGHT); //Kanal B uchun tormozni yoqing delay (1000); } Download 455.21 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling