วันพฤหัสบดี, มิถุนายน 5, 2025
Latest:
วิชาการเขียนโปรแกรมควบคุมหุ่นยนต์

คำสั่งเดินหน้า ถอยหลัง เลี้ยวซ้าย บอร์ด ipst

จากตัวอย่างโค้ดที่นักเรียนเห็นต่อไปนี้เป็นการเขียนคำสั่งให้หุ่นเดินหน้า ถอยหลัง เดินหน้า เลี่้ยวซ้าย ตรงไป

ตัวอย่างโค้ดอย่างง่าย

 

#include <ipst.h>
void setup()
{
  setTextSize(3);     
  glcd (0,0,"ok"); 
  }
void loop()
{
  if (sw_OK()) 
  {
  motor(1,50);  // ขับมอเตอร์ข้างที่ 1 ด้วยกำลัง 50 (มากสุดคือ 100) 
  motor(2,50);  // ขับมอเตอร์ข้างที่ 2 ด้วยกำลัง 50 (มากสุดคือ 100)
  delay(3000);  // ขับมอเตอร์นาน 3 วินาที เวลา 1000 เท่ากับ 1 วินาที
  motor_stop(ALL);  //สั่งให้มอเตอร์ทั้งสองหยุดทำงานทั้ง 2 ข้าง
  delay(500);   //มอเตอร์ทั้งสองหยุดทำงาน 0.5 วินาที
  motor(1,-50); 
  motor(2,-50); 
  delay(3000);  
  motor_stop(ALL);  
  delay(500);      
  motor(1,50);  
  motor(2,50);  
  delay(2500);     
  motor_stop(ALL);
  delay(500);
  motor(1,0);  // ขับมอเตอร์ข้างที่ 1 ด้วยกำลัง 0 (มากสุดคือ 100) 
  motor(2,40); // ขับมอเตอร์ข้างที่ 2 ด้วยกำลัง 40 (หุ่นเลี้ยวซ้าย)
  delay(1200);
  motor(1,50); 
  motor(2,50);  
  delay(3000);  
  motor_stop(ALL);
  }
}

กดย้อนกลับเพื่อเข้าไปยังหน้าหลักของวิชาการเขียนโปรแกรมควบคุมหุ่นยนต์ IPST –>click

slot gacor hari ini slot qris slot gacor maxwin slot online slot gacor gampang menang slot gacor hari ini slot online slot slot slot guci777 wortel21 guci777 guci777 wortel21 wortel21 wortel21 guci777