วิชาการเขียนโปรแกรมควบคุมหุ่นยนต์

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

การใช้คำสั่งเลี้ยวซ้ายหรือขวาบอร์ด 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 guci777 fafatogel fafatogel fafatogel fafatogel agen138 slot agen138 slot data hk bola slot bolaslot99 bola slot agen138 link alternatif koin138 link alternatif agen138 slot ag138 slot slot gacor slot thailand