BTW, trying to modify the library for use on the Pinguino, kaso wala palang boolean datatype ang pinguino T_T . Anong magandang gamitin for it? Integer?
Yup, I agree, kelangan ng mas mataas na resolution which is why balak din po namin i-modify yung P-bot by adding more sensors... And thanks for the library, too! Sana madali lang itong i-port for the Pinguino.
pwede ko bang pc controlled ung p-bot ung galing sa e-gizmo?
6.1.1. Command Structure"Dxx [Command_Code] [Parameter1] [Parameter2] <Return><Line Feed>" (At least 10mS Transmission interval)"# This is a comment"Comments (preceeded by a character '#')Running at 9600bps / 4800bps baudrate.Every packet must start with ascii character 'D' (0x44) to indicate the start of a D-Protocol packet.xx is the device/module number.Each string of the D-Protocol packet is preceeded by the ascii <SPACE> character 0x20. This includes the last string of the packet.The Command_Code is a fixed length(4 characters) string which tells what register to accessThere may be cases that a specific command code requires supporting parameters, these are optional depending on the command used. Parameters are limited to maximum of 6 characters only. No limit on the minimum number of characters for the parameter.D-Protocol command is terminated by a return (0x0D) and line feed (0x0A) characters.
const int LS[3] = {5,6,7};const int M1DIR = 8; //HIGH - FORWARDconst int M2DIR = 11;const int M1RUN = 9; //RIGHTconst int M2RUN = 10; //LEFT void setup(){ for(int i=0;i<3;i++) { pinMode(LS[i],INPUT); } pinMode(M1RUN,OUTPUT); pinMode(M2RUN,OUTPUT); pinMode(M1DIR,OUTPUT); pinMode(M2DIR,OUTPUT); digitalWrite(M1RUN,HIGH); digitalWrite(M1DIR,HIGH);}void loop(){ if(digitalRead(LS[1]==HIGH&&LS[2]==HIGH&&LS[3]==HIGH))//straight { analogWrite(M1RUN,200); analogWrite(M2RUN,200); digitalWrite(M1DIR,HIGH); digitalWrite(M2DIR,HIGH); } else if(digitalRead(LS[1]==LOW&&LS[2]==HIGH&&LS[3]==HIGH))//slightly left { analogWrite(M1RUN,100); analogWrite(M2RUN,200); digitalWrite(M1DIR,LOW); digitalWrite(M2DIR,HIGH); } else if(digitalRead(LS[1]==LOW&&LS[2]==LOW&&LS[3]==HIGH))//sharp left { analogWrite(M1RUN,50); analogWrite(M2RUN,200); digitalWrite(M1DIR,LOW); digitalWrite(M2DIR,HIGH); } else if(digitalRead(LS[1]==HIGH&&LS[2]==HIGH&&LS[3]==LOW))//slightly right { analogWrite(M1RUN,200); analogWrite(M2RUN,100); digitalWrite(M1DIR,HIGH); digitalWrite(M2DIR,HIGH); } else if(digitalRead(LS[1]==HIGH&&LS[2]==LOW&&LS[3]==LOW))//sharp right { analogWrite(M1RUN,200); analogWrite(M2RUN,50); digitalWrite(M1DIR,HIGH); digitalWrite(M2DIR,LOW); } else if(digitalRead(LS[1]==LOW&&LS[2]==LOW&&LS[3]==LOW))//non sense { analogWrite(M1RUN,0); analogWrite(M2RUN,0); digitalWrite(M1DIR,LOW); digitalWrite(M2DIR,LOW); } delay(1000); }
sir tanong lng po.. lage kasing umilaw ung LED indicator ng line sensor ng pbot.. nabasa ko po sa manual, LED indicator should stay ON as long as nkatapat sa black tape, otherwise it will OFF.. bat po ba baliktad?pagtinakpan ko ng papel it turns OFF at pag walang papel it will ON...
look at it this way, ang sensors ay gumagana by detecting kung may reflection ng IR light o wala, kapag tinakkapan mo ng papel(ang puting papel ay may reflection) natural mawawala ilaw, kapag inalis mo papel at nakaangat ang PBot wala syang makikitang reflection so nakaON normally ang ilaw.Ang black lines ay nagaabsorb ng ilaw kaya walang masyadong reflection ng IR light.remember kapag nakasangat or masyadong malayo ang pbot sa sahig, iilaw ang mga sensor indicators na yan.
referencing back dun sa code na inipost mo....gumagamit ka ng ganito analogWrite(M2RUN,50);This is good when controlling the speed pero it cannot go all the way down to 0, sa mga test ko before, its usually above 100 upto 255,Try mo gawing 255 to see if aandar, Tama ka, another factor is maaring low batt na sya.
hindi analoWrite ang problema kundi yung value na 50, normally ang minimum for P-Bot IIRC is around 120 yata...