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

การใช้คำสั่งเลี้ยวซ้ายหรือขวา

การใช้คำสั่งเลี้ยวซ้ายหรือขวาบอร์ด ipst อย่างง่ายโดยการใช้เซนเซอร์

#include <ipst.h>
int L,R,CL=400,CR=400;
void setup(){
 OK();
}
void loop(){
 L=analog(0);
 R=analog(1);
 if(L>CL&&R>CR){
 fd(40);
 }
 else if(L<CL&&R>CR){
 tl(40);
 }
 else if(L>CL&&R<CR){
 tr(40);
 }
 else if(L<CL&&R<CR){
 fd(40);
 while(analog(0)>CR){     // A0 เจอพื้นสีขาวให้เลี้ยวซ้ายต่อไป
 sl(30);
 }
 while(analog(0)<CR){     // A0 เจอเส้นสีดำให้เลี้ยวขวาต่อไป
 sl(30);
 }
 }
}

 

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