'' ******************* '' * joystickSimple.spin '' * avec RADIO et série a 19200 '' * radio pin 20 et 21 '' * Marche avec JOYSTICKduBOT coté PC et MINIBOT en C# '' * servo right en p14 et left en pin 15 '' * '' ******************* CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR Long stack1[50] Long stack2[50] Byte myString[50] Byte comchar,prembit ,arg1,arg2,arg3,arg4 Long Time Long Lduree,Rduree,Nfois,Cduree Byte roule OBJ FullD : "Fullduplexserialplus" PUB Start Time:=cnt Lduree:=1460 'pulse en microsec sinon pas de valeur pour démarrer Rduree:=1460 'pulse en microsec fullD.start(20,21,0,2400) 'radio pins cognew(run, @stack2) readradio PUB readradio 'message like KjxAR -->arg1=65 -->arg2=82 prembit:= 75 'identify the bot repeat attendrebit 'waits prembit = K = char75 fullD.getstr(@myString) comchar := myString[0] 'en fait j pour Joystick le premier caractére aprés K arg1:=mystring[1] 'unused here arg2:=mystring[2] ' pour pulseleft joystick AXIS D arg3:=mystring[3] 'pour pulseright joystick AXIS C Nfois:=arg1 Lduree:=1274+(arg2*3) Rduree:=1274+(arg3*3) PUB pulseleft | duree duree:=Lduree !outa[15] waitcnt(((clkfreq/1_000_000) * duree) +cnt) 'clkfreq= 1seconde !outa[15] waitcnt ( Time+= clkfreq/50 ) PUB pulseright | duree duree:=Rduree !outa[14] waitcnt(((clkfreq/1_000_000)* duree) +cnt) !outa[14] waitcnt ( Time+= clkfreq/50 ) PUB run dira[14]~~ 'servo droit dira[15]~~ 'servo gauche outa[15]~ outa[14]~ Time:=cnt repeat pulseleft pulseright PUB attendrebit | bitlu bitlu:=0 repeat until (bitlu == prembit) bitlu:= fullD.rx