Você está na página 1de 22

Arduino UNO External Control

Of the many useful USB control platforms, the Arduino UNO R3 has turned out to be the most versatile that I have used in a long time I see these every!here !hich indicates to me that it !ill be here to stay for a !hile I have designed for other prototype platforms that haven"t al!ays been available !hen I needed them, so the availability and popularity of the Arduino series is important to me #ith $% digital I&O, t!o of !hich can be used as '#( Outputs, and ) analog I&O pins, it can do most anything that I need to get done, including running my *++ trains ,o get started I needed a s-etch to upload to the UNO that !ould interact !ith the '+ +ontrol program ,his !as fairly trivial using the serial com port in a case&s!itch routine I did add the ability to send the port and the port data in a single case instead of using separate cases for $ or . outputs It ma-es the +ontrol 'rogram more efficient in my opinion ,he s-etch is included later in this article /or the +ontrol 'rogram, I decided to use 0iberty Basic instead of 1isual Basic for the simplicity of the programing language 2ither one !ill !or- but I didn"t need a sledge hammer to s!at a fly 0iberty basic is very affordable !ith trial, basic, and pro versions I use the 3old version to get the most out of the program Along !ith the free!are 0B Booster program, I am able to create the e4e files that are easily secured In this case I am providing the te4t of the program as free for personal and educational use for both the s-etch and the +ontrol 'rogram /or more information go to !!! ,ech3uy*avid com after (ay $, 5.$%

,he Arduino UNO s-etch is listed belo! Simply copy and paste into the ino file Be sure to create the acg6 folder to contain the s-etch and control program && acg6 t4t April 7, 5.$% am$ && ,his s-etch uses a ne! 0iberty Basic 3UI that !as created to demonstrate control && of the Arduino UNO Input and Output functions, along !ith Slider +ontrols, Bar 3raphs, && and a Real ,ime 'lot function for A5 and A3 && Not suitable for commercial use, use at your o!n ris&& /or details see http8&&!!! techguydavid com&,3*page9 html && /ree for personal or educational use only && int analog'in. : .; int 1A0. : .; int 1A0$ : .; int 1A07 : .; int 1A06 : .; int 1A0$. : .; int 1A0$$ : .; int 1A0$5 : .; int 1A0$3 : .; char s; void setup<=> for<int i:5;i?7;i@@= > pin(ode<i, IN'U,A'U00U'=; B for<int i:7;i?$%;i@@= > pin(ode<i,OU,'U,=; B Serial begin<6)..=; B void loop<= > s:Serial read<=; s!itch<s= > case CaC 8Serial println<analogRead<A5==; &&Reads Analog 5 brea-; case CbC 8Serial println<analogRead<A3==; &&Reads Analog 3

brea-; case CcC 8Serial println<analogRead<A%==; &&Reads Analog % brea-; case CdC 8Serial println<analogRead<A9==; &&Reads Analog 9 brea-; case CeC 8Serial println <digitalRead<5==; &&Send *igital 'in 5 data brea-; case CfC 8Serial println <digitalRead<3==; &&Send *igital 'in 3 data brea-; case CgC 8Serial println <digitalRead<%==; &&Send *igital 'in % data brea-; case ChC 8Serial println <digitalRead<9==; &&Send *igital 'in 9 data brea-; case CiC 8Serial println <digitalRead<)==; &&Send *igital 'in ) data brea-; case CDC 8Serial println <digitalRead<E==; &&Send *igital 'in E data brea-; case C$C8 &&set '#(6 delay<$.=; 1A0.:Serial read<=; &&Read '#(6 1alue analog#rite<6, 1A0.=; brea-; case C5C8 &&set '#($. delay<$.=; 1A0$:Serial read<=; &&Read '#($. 1alue &&Serial println <1A0$=; analog#rite<$., 1A0$=; brea-; case C3C8 &&*igital 'in 7 delay<$.=; 1A07:Serial read<=; &&Read 1alue delay<$.=; &&Serial println <1A07=; if <1A07::.= digital#rite<7,0O#=; if <1A07::$= digital#rite<7,FI3F=; brea-; case C%C8 &&*igital 'in 6 delay<$.=; 1A06:Serial read<=; &&Read 1alue delay<$.=; &&Serial println <1A06=;

if <1A06::.= digital#rite<6,0O#=; if <1A06::$= digital#rite<6,FI3F=; brea-; case C9C8 &&*igital 'in $. delay<$.=; 1A0$.:Serial read<=; &&Read 1alue delay<$.=; &&Serial println <1A0$.=; if <1A0$.::.= digital#rite<$.,0O#=; if <1A0$.::$= digital#rite<$.,FI3F=; brea-; case C)C8 &&*igital 'in $$ delay<$.=; 1A0$$:Serial read<=; &&Read 1alue delay<$.=; &&Serial println <1A0$$=; if <1A0$$::.= digital#rite<$$,0O#=; if <1A0$$::$= digital#rite<$$,FI3F=; brea-; case CEC8 &&*igital 'in $5 delay<$.=; 1A0$5:Serial read<=; &&Read 1alue delay<$.=; &&Serial println <1A0$5=; if <1A0$5::.= digital#rite<$5,0O#=; if <1A0$5::$= digital#rite<$5,FI3F=; brea-; case C7C8 &&*igital 'in $3 delay<$.=; 1A0$3:Serial read<=; &&Read 1alue delay<$.=; &&Serial println <1A0$3=; if <1A0$3::.= digital#rite<$3,0O#=; &&3UI +ontrol if <1A0$3::$= digital#rite<$3,FI3F=; &&3UI +ontrol if <1A0$3::G$= digital#rite<$3,0O#=; &&Serial (onitor +ontrol brea-; case C6C8 &&*igital 'in $3 digital#rite<$3,FI3F=; brea-; B B

,he control program is a little longer because I have included slider controls, bar graphs, chec-bo4es and line graphs as e4amples for other control needs Again it is provided here for personal and educational uses only Not suitable for commercial use Use at your o!n risC acg60B t4t April 7, 5.$% am$ by *avid *eane, 1idalia, 3A C Arduino UNO 24ternal +ontrol by *avid *eane (arch, 5.$% C ,his soft!are is provided Has isH and is not suitable for commercial use C ,his soft!are is provided for demonstration purposes only C Use at you o!n risC /ree for personall or educational use only C contact *avidI,ech3uy*avid com

nomain!in #indo!#idth : $3.. #indo!Feight : ).. Upper0eftJ : $. Upper0eftK : $. Bac-ground+olorL: HlightgrayH global slide$K, slide5K, slide5K, slide%J, +omJL, 1A06, 1A0$., cset global !riting, port.val, port$val, port5val, port3val, 'lotActive global val.Bar, val$Bar,tempslide%J, S*7, S*$$, S*$5, S*$3 slide$K:5.. C start at .M slide5K:5.. C start at .M slide%J:$. cset:.8!riting:.8port.val:.8port$val:.8port5val:.8port3val:.8'lotActive:. S*7:.8S*$$:.8S*$5:.8S*$3:. *I( dat$<9..=8*I( dat5 <9..= C:::::::::::::::::::::::: define controls ::::::::::::::::::::::::::::::::::::::::::: te4tbo4 N$ comport, 9.,59,E9,5. staticte4t N$ setcom HSet 1alid +om 'ort 1alue FereH, $3.,5E,$79,5. button N$ connect$,H+onnectH,OconnectcomP, U0, 9., 9., E9, 5. staticte4t N$ +ON+O( H+lic- here to +onnectH, $3.,9.,$79,5. staticte4t N$ Rate+hec- HSample Rate : $ FQH, %9.,5E,$79,5. staticte4t N$ ,emp*ata HAAAH, %9.,%E,$79,5.

C1ertical Slider slide$ slide$Over:9.8slide$*o!n:$9.8slide$#idth:5.8slide$Feight:5.5 graphicbo4 N$ slide$ slide$Over, slide$*o!n, slide$#idth, slide$Feight staticte4t N$ slide$t4t. H1alueH, slide$OverG9, slide$*o!n @5.9, 7., 5. staticte4t N$ slide$t4t$ H.MH, slide$Over @ 59, slide$*o!n @ $6., 9., $9 staticte4t N$ slide$t4t5 H$..MH, slide$Over @59, slide$*o!n G 9, 9., $9 staticte4t N$ slide$t4t3 H.MH, slide$Over, slide$*o!n @ 559, 9., 5. staticte4t N$ 1Slide$t4t$ H'#(G'in6H, slide$OverG$., slide$*o!nG%9, 6., 5. staticte4t N$ 1Slide$t4t$A H. G $..MH, slide$OverG$., slide$*o!nG59, E9, 5. C1ertical Slider slide5 slide5Over:$9.8slide5*o!n:$9.8slide5#idth:5.8slide5Feight:5.5 graphicbo4 N$ slide5 slide5Over, slide5*o!n, slide5#idth, slide5Feight staticte4t N$ slide5t4t. H1alueH, slide5OverG9, slide5*o!n @5.9, 7., 5. staticte4t N$ slide5t4t$ H.MH, slide5Over @ 59, slide5*o!n @ $6., 9., $9 staticte4t N$ slide5t4t5 H$..MH, slide5Over @59, slide5*o!n G 9, 9., $9 staticte4t N$ slide5t4t3 H.MH, slide5Over, slide5*o!n @ 559, 9., 5. staticte4t N$ 1Slide5t4t$ H'#(G'in$.H, slide5OverG$., slide5*o!nG%9, 6., 5. staticte4t N$ 1Slide5t4t$A H. G $..MH, slide5OverG$., slide5*o!nG59, E9, 5. vbar.Over:3..8vbar.*o!n:$9. graphicbo4 N$ 1bar., vbar.Over, vbar.*o!n, 59, 5.. staticte4t N$ 1Bar.t4t$ H Read A5H, vbar.OverG$., vbar.*o!nG%9, 7., 5. staticte4t N$ 1Bar.t4t$A H. G $..H, vbar.OverG9, vbar.*o!nG59, 9., 5. staticte4t N$ 1Bar.t4t5 H1alueH, vbar.OverG9, vbar.*o!n@5.9, 9., 5. staticte4t N$ 1Bar.t4t3 H.MH, vbar.Over, vbar.*o!n@559,%.,5. staticte4t N$ 1Bar.t4t% H.MH, vbar.Over @ 57, vbar.*o!n @ $6., 9., $9 staticte4t N$ 1Bar.t4t9 H$..MH, vbar.Over @57, vbar.*o!n G 9, 9., $9 vbar$Over:%..8vbar$*o!n:$9. graphicbo4 N$ 1bar$, vbar$Over, vbar$*o!n, 59, 5.. staticte4t N$ 1Bar$t4t$ H Read A3H, vbar$OverG$., vbar$*o!nG%9, 7., 5. staticte4t N$ 1Bar$t4t$A H. G $..H, vbar$OverG9, vbar$*o!nG59, 9., 5. staticte4t N$ 1Bar$t4t5 H1alueH, vbar$OverG9, vbar$*o!n@5.9, 9., 5. staticte4t N$ 1Bar$t4t3 H.MH, vbar$Over, vbar$*o!n@559,%.,5. staticte4t N$ 1Bar$t4t% H.MH, vbar$Over @ 57, vbar$*o!n @ $6., 9., $9 staticte4t N$ 1Bar$t4t9 H$..MH, vbar$Over @57, vbar$*o!n G 9, 9., $9 vbar5Over:9..8vbar5*o!n:$9. graphicbo4 N$ 1bar5, vbar5Over, vbar5*o!n, 59, 5..

staticte4t N$ 1Bar5t4t$ HRead A%H, vbar5OverG$., vbar5*o!nG%9, 7., 5. staticte4t N$ 1Bar5t4t$A H. G $..H, vbar5OverG9, vbar5*o!nG59, 9., 5. staticte4t N$ 1Bar5t4t5 H1alueH, vbar5OverG9, vbar5*o!n@5.9, 9., 5. staticte4t N$ 1Bar5t4t3 H.MH, vbar5Over, vbar5*o!n@559,%.,5. staticte4t N$ 1Bar5t4t% H.MH, vbar5Over @ 57, vbar5*o!n @ $6., 9., $9 staticte4t N$ 1Bar5t4t9 H$..MH, vbar5Over @57, vbar5*o!n G 9, 9., $9 vbar3Over:)..8vbar3*o!n:$9. graphicbo4 N$ 1bar3, vbar3Over, vbar3*o!n, 59, 5.. staticte4t N$ 1Bar3t4t$ HRead A9H, vbar3OverG$., vbar3*o!nG%9, 7., 5. staticte4t N$ 1Bar3t4t$A H. G $..H, vbar3OverG9, vbar3*o!nG59, 9., 5. staticte4t N$ 1Bar3t4t5 H1alueH, vbar3OverG9, vbar3*o!n@5.9, 9., 5. staticte4t N$ 1Bar3t4t3 H.MH, vbar3Over, vbar3*o!n@559,%.,5. staticte4t N$ 1Bar3t4t% H.MH, vbar3Over @ 57, vbar3*o!n @ $6., 9., $9 staticte4t N$ 1Bar3t4t9 H$..MH, vbar3Over @57, vbar3*o!n G 9, 9., $9 +hec-bo4Over:9.8+hec-bo4*o!n:%9. staticte4t N$ +Bo4Set, HSetH,+hec-bo4Over,+hec-bo4*o!n@%, 3.,59 chec-bo4 N$ chec-bo47, H*7 H, Ochec-bo47SetP, Ochec-bo47ResetP, +hec-bo4Over@9., +hec-bo4*o!n, %., 59 chec-bo4 N$ chec-bo4$$, H*$$H, Ochec-bo4$$SetP, Ochec-bo4$$ResetP, +hec-bo4Over@$.., +hec-bo4*o!n, %., 59 chec-bo4 N$ chec-bo4$5, H*$5H, Ochec-bo4$5SetP, Ochec-bo4$5ResetP, +hec-bo4Over@$9., +hec-bo4*o!n, %., 59 chec-bo4 N$ chec-bo4$3, H*$3H, Ochec-bo4$3SetP, Ochec-bo4$3ResetP, +hec-bo4Over@5.., +hec-bo4*o!n, %., 59 staticte4t N$ +Bo4Read, HR2A*H,+hec-bo4Over@3..,+hec-bo4*o!n@%, 9.,59 staticte4t N$ Read*5, H.H, +hec-bo4Over@399, +hec-bo4*o!n@%, 3., 5. staticte4t N$ Read*3, H.H, +hec-bo4Over@%.9, +hec-bo4*o!n@%, 3., 5. staticte4t N$ Read*%, H.H, +hec-bo4Over@%99, +hec-bo4*o!n@%, 3., 5. staticte4t N$ Read*9, H.H, +hec-bo4Over@9.9, +hec-bo4*o!n@%, 3., 5. staticte4t N$ Read*), H.H, +hec-bo4Over@999, +hec-bo4*o!n@%, 3., 5. staticte4t N$ Read*E, H.H, +hec-bo4Over@).9, +hec-bo4*o!n@%, 3., 5. staticte4t N$ Read*,4t5, H*5H, +hec-bo4Over@39., +hec-bo4*o!n@53, %., 59 staticte4t N$ Read*,4t3, H*3H, +hec-bo4Over@%.., +hec-bo4*o!n@53, %., 59 staticte4t N$ Read*,4t%, H*%H, +hec-bo4Over@%9., +hec-bo4*o!n@53, %., 59 staticte4t N$ Read*,4t9, H*9H, +hec-bo4Over@9.., +hec-bo4*o!n@53, %., 59 staticte4t N$ Read*,4t), H*)H, +hec-bo4Over@99., +hec-bo4*o!n@53, %., 59 staticte4t N$ Read*,4tE, H*EH, +hec-bo4Over@).., +hec-bo4*o!n@53, %., 59 staticte4t N$ +Bo4*Sets, HArduino *7, *$$, *$5, and *$3 OutputsH, +hec-bo4Over, +hec-bo4*o!n@%9,3..,59

staticte4t N$ +Bo4*Reads, HArduino *5 through *E InputsH, +hec-bo4Over@3.., +hec-bo4*o!n@%9,3..,59 plot$over:EE98plot$do!n:598plot$!idth:9..8plot$height:5.5 staticte4t N$ plot$title HAnalog A5 1alueH, plot$over@$.., plot$do!nG5., $9., 5. graphicbo4 N$ plot$, plot$over, plot$do!n, plot$!idth, plot$height staticte4t N$ plot$top H$..MH, plot$overG3%, plot$do!n, 3%, 5. staticte4t N$ plot$bot H.MH, plot$overG5%, plot$do!n@$6., 5%, 5. staticte4t N$ plot5title HAnalog A3 1alueH, plot$over@$.., plot$do!n@5$., $9., 5. graphicbo4 N$ plot5, plot$over, plot$do!n@53., plot$!idth, plot$height staticte4t N$ plot5top H$..MH, plot$overG3%, plot$do!n@53., 3%, 5. staticte4t N$ plot5bot H.MH, plot$overG5%, plot$do!n@$6.@53., 5%, 5. CForiRontal +hart Speed Slider slide%Over:plot$over@9.8slide%*o!n:%E98slide%#idth:$.58slide%Feight:$6 graphicbo4 N$ slide% slide%Over, slide%*o!n, $.5, $6 staticte4t N$ slide%t4t. H+hart SpeedH, slide%Over@$5., slide%*o!n@5.G5., 7., 5. staticte4t N$ slide%t4t3 H$H, slide%Over@5.., slide%*o!n@5.G5., 7., 5. Cstarting value to get chart moving

C:::::::::::::::::::: begin operations :::::::::::::::::::::::::::::::::::::::::::::::: open HArduino +ontrol by *avid *eane at ,ech3uy*avid comH for !indo!Anf as N$ N$ Htrapclose OSuitPH N$ Hfont arial $.H 'rint N$ comport, H+O($H timer $..., OlooprP N$ setcom HTfont arial $.H N$ Rate+hec- HTfont arial $$ boldH N$ setcom HTfont arial $$ boldH N$ +ON+O( HTfont arial $$ boldH C:::::::::::::::::: Slide$ Operations ::::::: N$ slide$t4t. HTfont arial $.H N$ slide$t4t$ HTfont arial $.H N$ slide$t4t5 HTfont arial $.H N$ slide$t4t3 HTfont arial $.H N$ 1Slide$t4t$ HTfont arial $$ boldH N$ 1Slide$t4t$A HTfont arial $$ boldH

N$ slide$ Hdo!nH N$ slide$ Hfill buttonfaceH N$ slide$ Hbac-color blueH N$ slide$ Hline 6 . 6 5..H N$ slide$ Hplace . H;slide$K@% N$ slide$ Hbo4filled 5. H;slide$KG% N$ slide$ H!hen leftButton(ove Omouseslide$PH N$ slide$ H!hen leftButton*o!n Omouseslide$PH N$ slide$ H!hen characterInput O-eyslide$PH C:::::::::::::::::: Slide5 Operations ::::::: N$ slide5t4t. HTfont arial $.H N$ slide5t4t$ HTfont arial $.H N$ slide5t4t5 HTfont arial $.H N$ slide5t4t3 HTfont arial $.H N$ 1Slide5t4t$ HTfont arial $$ boldH N$ 1Slide5t4t$A HTfont arial $$ boldH N$ slide5 Hdo!nH N$ slide5 Hfill buttonfaceH N$ slide5 Hbac-color cyanH N$ slide5 Hline 6 . 6 5..H N$ slide5 Hplace . H;slide5K@% N$ slide5 Hbo4filled 5. H;slide5KG% N$ slide5 H!hen leftButton(ove Omouseslide5PH N$ slide5 H!hen leftButton*o!n Omouseslide5PH N$ slide5 H!hen characterInput O-eyslide5PH N$ 1Bar.t4t$ HTfont arial $$ boldH N$ 1Bar.t4t5 HTfont arial $.H N$ 1Bar.t4t3 HTfont arial $.H N$ 1Bar.t4t$A HTfont arial $$ boldH N$ 1Bar.t4t% HTfont arial $.H N$ 1Bar.t4t9 HTfont arial $.H N$ 1Bar$t4t$ HTfont arial $$ boldH N$ 1Bar$t4t5 HTfont arial $.H N$ 1Bar$t4t3 HTfont arial $.H N$ 1Bar$t4t$A HTfont arial $$ boldH

N$ 1Bar$t4t% HTfont arial $.H N$ 1Bar$t4t9 HTfont arial $.H N$ 1Bar5t4t$ HTfont arial $$ boldH N$ 1Bar5t4t5 HTfont arial $.H N$ 1Bar5t4t3 HTfont arial $.H N$ 1Bar5t4t$A HTfont arial $$ boldH N$ 1Bar5t4t% HTfont arial $.H N$ 1Bar5t4t9 HTfont arial $.H N$ 1Bar3t4t$ HTfont arial $$ boldH N$ 1Bar3t4t5 HTfont arial $.H N$ 1Bar3t4t3 HTfont arial $.H N$ 1Bar3t4t$A HTfont arial $$ boldH N$ 1Bar3t4t% HTfont arial $.H N$ 1Bar3t4t9 HTfont arial $.H N$ Read*5 HTfont arial $$ boldH N$ Read*3 HTfont arial $$ boldH N$ Read*% HTfont arial $$ boldH N$ Read*9 HTfont arial $$ boldH N$ Read*) HTfont arial $$ boldH N$ Read*E HTfont arial $$ boldH 'RIN, N$ 1bar., Hbac-color redH 'RIN, N$ 1bar., H'lace . 5..H 'RIN, N$ 1bar., H*O#NH 'RIN, N$ 1bar., H+0SH 'RIN, N$ 1bar$, Hbac-color cyanH 'RIN, N$ 1bar$, H'lace . 5..H 'RIN, N$ 1bar$, H*O#NH 'RIN, N$ 1bar$, H+0SH 'RIN, N$ 1bar5, Hbac-color blueH 'RIN, N$ 1bar5, H'lace . 5..H 'RIN, N$ 1bar5, H*O#NH 'RIN, N$ 1bar5, H+0SH 'RIN, N$ 1bar3, Hbac-color greenH 'RIN, N$ 1bar3, H'lace . 5..H

'RIN, N$ 1bar3, H*O#NH 'RIN, N$ 1bar3, H+0SH N$ +Bo4Read HTfont arial $$ boldH N$ +Bo4Set HTfont arial $$ boldH N$ +Bo4*Reads HTfont arial $$ boldH N$ +Bo4*Sets HTfont arial $$ boldH N$ plot$title HTfont arial $$ boldH N$ plot5title HTfont arial $$ boldH print N$ plot$, Hup; fill blac-H print N$ plot$, Hplace . $59H Cover, do!n print N$ plot$, Hdo!nH print N$ plot5, Hup; fill blac-H print N$ plot5, Hplace . $59H Cover, do!n print N$ plot5, Hdo!nH C Init chart cyan values to Rero on the chart for dattRero : $ to 9.. dat$<dattRero=:5.. dat5<dattRero=:5.. ne4t dattRero N$ slide% Hdo!nH N$ slide% Hfill buttonfaceH N$ slide% Hbac-color blac-H N$ slide% Hline . 7 $5. 7H N$ slide% Hplace H;slide%JG%;H . ; bo4filled H;slide%J@%;H $EH N$ slide% H!hen leftButton(ove Omouseslide%PH N$ slide% H!hen leftButton*o!n Omouseslide%PH N$ slide% H!hen characterInput O-eyslide%PH !ait OlooprP Cdeactivate timer timer . If cset:$ then !riting:$ Cdisable send data !hile reading data

C::::::::::::::::::::::: dispaly Analog 5 value on 1bar . :::::::::::::: print NS+O((, HaH call 'ause 59 !hile lof<NS+O((= ?U. chrs:lof<NS+O((= cL : inputL<NS+O((, chrs= !end port.val:1al<cL=&$. 5%8val.Bar:5..G<5Vport.val= print N$ 1bar., H+0SH print N$ 1bar., Hbo4filled 3) H;val.Bar8print N$ 1Bar.t4t3, port.val;HMH C::::::::::::::::::::::: dispaly Analog 3 value on 1bar $ :::::::::::::: print NS+O((, HbH call 'ause 59 !hile lof<NS+O((= ?U. chrs:lof<NS+O((= cL : inputL<NS+O((, chrs= !end port$val:1al<cL=&$. 5%8val$Bar:5..G<5Vport$val= print N$ 1bar$, H+0SH print N$ 1bar$, Hbo4filled 3) H;val$Bar8print N$ 1Bar$t4t3, port$val;HMH C::::::::::::::::::::::: dispaly Analog % value on 1bar 5 :::::::::::::: print NS+O((, HcH call 'ause 59 !hile lof<NS+O((= ?U. chrs:lof<NS+O((= cL : inputL<NS+O((, chrs= !end port5val:1al<cL=&$. 5%8val5Bar:5..G<5Vport5val= print N$ 1bar5, H+0SH print N$ 1bar5, Hbo4filled 3) H;val5Bar8print N$ 1Bar5t4t3, port5val;HMH C::::::::::::::::::::::: dispaly Analog 9 value on 1bar 3 :::::::::::::: print NS+O((, HdH call 'ause 59 !hile lof<NS+O((= ?U. chrs:lof<NS+O((= cL : inputL<NS+O((, chrs= !end port3val:1al<cL=&$. 5%8val3Bar:5..G<5Vport3val= print N$ 1bar3, H+0SH print N$ 1bar3, Hbo4filled 3) H;val3Bar8print N$ 1Bar3t4t3, port3val;HMH C::::::::::::::::::::::: get and print *5 *ata :::::::::::::::::

print NS+O((, HeH call 'ause $. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= d5L : inputL<NS+O((, chrs= !end print N$ Read*5, d5L C::::::::::::::::::::::: get and print *3 *ata ::::::::::::::::: print NS+O((, HfH call 'ause $. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= d3L : inputL<NS+O((, chrs= !end print N$ Read*3, d3L C::::::::::::::::::::::: get and print *% *ata ::::::::::::::::: print NS+O((, HgH call 'ause $. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= d%L : inputL<NS+O((, chrs= !end print N$ Read*%, d%L C::::::::::::::::::::::: get and print *9 *ata ::::::::::::::::: print NS+O((, HhH call 'ause $. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= d9L : inputL<NS+O((, chrs= !end print N$ Read*9, d9L C::::::::::::::::::::::: get and print *) *ata ::::::::::::::::: print NS+O((, HiH call 'ause $. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= d)L : inputL<NS+O((, chrs= !end print N$ Read*), d)L C::::::::::::::::::::::: get and print *E *ata ::::::::::::::::: print NS+O((, HDH

call 'ause $. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= dEL : inputL<NS+O((, chrs= !end print N$ Read*E, dEL C::::::::::::::::::::::: Set *7 *ata ::::::::::::::::: print N$ chec-bo47, HvalueW vLH print N$ ,emp*ata, vL If vL:HsetH and S*7:. then S*7:$ print NS+O((, H3H; print NS+O((, chrL<$= 2nd If If vL:HresetH and S*7:$ then S*7:. print NS+O((, H3H; print NS+O((, chrL<.= 2nd If C::::::::::::::::::::::: Set *$$ *ata ::::::::::::::::: print N$ chec-bo4$$, HvalueW vLH print N$ ,emp*ata, vL If vL:HsetH and S*$$:. then S*$$:$ print NS+O((, H)H; print NS+O((, chrL<$= 2nd If If vL:HresetH and S*$$:$ then S*$$:. print NS+O((, H)H; print NS+O((, chrL<.= 2nd If C::::::::::::::::::::::: Set *$5 *ata ::::::::::::::::: print N$ chec-bo4$5, HvalueW vLH print N$ ,emp*ata, vL If vL:HsetH and S*$5:. then S*$5:$ print NS+O((, HEH; print NS+O((, chrL<$= 2nd If If vL:HresetH and S*$5:$ then

sd$5:. print NS+O((, HEH; print NS+O((, chrL<.= 2nd If C::::::::::::::::::::::: Set *$3 *ata ::::::::::::::::: print N$ chec-bo4$3, HvalueW vLH print N$ ,emp*ata, vL If vL:HsetH and S*$3:. then S*$3:$ print NS+O((, H7H; print NS+O((, chrL<$= 2nd If If <vL:HresetH= and <S*$3:$= then S*$3:. print NS+O((, H7H; print NS+O((, chrL<.= 2nd If call plot.$ !riting:. 2nd If timer 9.., OlooprP !ait C:::::::::::::::::::: Subroutines and Branches ::::::::::::::::::::::::::: OconnectcomP If cset:. then 'rint N$ comport, HTcontentsW +omJLH; C,his retrieves the contents of the te4tbo4 and places them into the variable, +omJL open +omJL;H86)..,n,7,$H for random as NS+O(( cset:$ print NS+O((, H$H; print NS+O((, chrL<.= call 'ause $.. print NS+O((, H5H; print NS+O((, chrL<.= call 'ause $.. print NS+O((, H3H; print NS+O((, chrL<.= call 'ause $..

2nd If play!ave Hclic- !avH reps:. CBlin- 02* $3 three times if connected OagainP reps:reps@$ print NS+O((, H7H; print NS+O((, chrL<$= call 'ause $.. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= cL : inputL<NS+O((, chrs= print cL !end call 'ause 9.. print NS+O((, H7H; print NS+O((, chrL<.= call 'ause $.. !hile lof<NS+O((= ?U. chrs:lof<NS+O((= cL : inputL<NS+O((, chrs= print cL !end call 'ause 9.. if reps?3 then goto OagainP !ait Omouseslide$P slide$K:(ouseK if slide$K?. then slide$K:. if slide$KU5.. then slide$K:5.. goto OupdatecontrolP !ait O-eyslide$P -ey:asc<rightL<In-eyL,$==

if -ey:A1XAU' then slide$K:slide$KG<slide$KU.= if -ey:A1XA*O#N then slide$K:slide$K@<slide$K?5..= goto OupdatecontrolP !ait Omouseslide5P slide5K:(ouseK if slide5K?. then slide5K:. if slide5KU5.. then slide5K:5.. goto OupdatecontrolP !ait O-eyslide5P -ey:asc<rightL<In-eyL,$== if -ey:A1XAU' then slide5K:slide5KG<slide5KU.= if -ey:A1XA*O#N then slide5K:slide5K@<slide5K?5..= goto OupdatecontrolP Omouseslide%P slide%J:(ouseJ if slide%J?. then slide%J:. if slide%JU$.. then slide%J:$.. goto OupdatecontrolP O-eyslide%P slide:% -ey:asc<rightL<In-eyL,$== if -ey:A1XA02/, then slide%J:slide%JG<slide%JU.= if -ey:A1XARI3F, then slide%J:slide%J@<slide%J?$..= goto OupdatecontrolP

!ait OupdatecontrolP timer . N$ slide$ Hfill buttonfaceH N$ slide$ Hbac-color blueH N$ slide$ Hline 6 . 6 5..H N$ slide$ Hplace . H;slide$K@% N$ slide$ Hbo4filled 5. H;slide$KG%

print N$ slide$t4t3, Int<. 9 V <5.. G slide$K==;HMH If <cset:$ and !riting:.= then 1A06:599G<slide$K V <599&5..== print NS+O((, H$H; print NS+O((, chrL<1A06= 2nd If N$ slide5 Hfill buttonfaceH N$ slide5 Hbac-color cyanH N$ slide5 Hline 6 . 6 5..H N$ slide5 Hplace . H;slide5K@% N$ slide5 Hbo4filled 5. H;slide5KG% print N$ slide5t4t3, Int<. 9 V <5.. G slide5K==;HMH If <cset:$ and !riting:.= then 1A0$.:599G<slide5K V <599&5..== print NS+O((, H5H; print NS+O((, chrL<1A0$.= 2nd If N$ slide% Hfill buttonfaceH N$ slide% Hline . 7 $5. 7H N$ slide% Hplace H;slide%JG%;H . ; bo4filled H;slide%J@%;H $EH print N$ slide%t4t3, int<slide%J&$.= call 'ause $. timer 9.., OlooprP !ait Sub plot.$ C NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNN 'lotActive:$ step0R:int<slide%J&$.=Cchart speed . G $. if step0R?U. then print N$ plot$, Hup; fill blac-H Cerase chart if step0R?U. then print N$ plot5, Hup; fill blac-H Cerase chart C :::::: plot val.Bar <cyan= :::::::::::::::: dat$<9..=:val.BarG$ Cconvert .G$..M to 5..G. p4 do!n offset by $ for plot height : 5.5 for datt : $ to %66 Cshift left by $ dat$<datt=:dat$<datt@$=

ne4t datt 4plot$:9.. print N$ plot$, Hgoto 9.. H;dat$<9..= print N$ plot$, Hcolor redH print N$ plot$, Hdo!nH for datt:9.. to $ step G$ print N$ plot$,Hgoto H;4plot$;H H;dat$<datt= 4plot$:4plot$Gstep0R ne4t datt print N$ plot$, HupH C :::::: plot val$Bar <red= ::::::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ dat5<9..=:val$BarG$Cconvert .G$..M to 5..G. p4 do!n for datt : $ to %66 Cshift left by $ dat5<datt=:dat5<datt@$= ne4t datt 4plot5:9.. print N$ plot5, Hgoto 9.. H;dat5<9..= print N$ plot5, Hcolor cyanH print N$ plot5, Hdo!nH for datt:9.. to $ step G$ print N$ plot5,Hgoto H;4plot5;H H;dat5<datt= 4plot5:4plot5Gstep0R ne4t datt print N$ plot5, HupH +all Update+tls 'lotActive:. 2nd Sub

Ochec-bo45SetP !ait Ochec-bo45ResetP !ait Ochec-bo43SetP Csend code !ait Ochec-bo43ResetP

Csend code !ait Ochec-bo4%SetP Csend code !ait Ochec-bo4%ResetP Csend code !ait Ochec-bo49SetP Csend code !ait Ochec-bo49ResetP Csend code !ait Ochec-bo4)SetP Csend code !ait Ochec-bo4)ResetP Csend code !ait Ochec-bo4ESetP Csend code !ait Ochec-bo4EResetP Csend code !ait Ochec-bo47SetP !ait Ochec-bo47ResetP !ait Ochec-bo4$$SetP !ait Ochec-bo4$$ResetP !ait Ochec-bo4$5SetP !ait Ochec-bo4$5ResetP !ait Ochec-bo4$3SetP !ait Ochec-bo4$3ResetP

!ait sub 'ause mil t:timeL<HmillisecondsH= !hile timeL<HmillisecondsH=?t@mil !end end sub Sub Update+tls N$ slide$ Hfill buttonfaceH N$ slide$ Hbac-color blueH N$ slide$ Hline 6 . 6 5..H N$ slide$ Hplace . H;slide$K@% N$ slide$ Hbo4filled 5. H;slide$KG% print N$ slide$t4t3, Int<. 9 V <5.. G slide$K==;HMH If <cset:$ and !riting:.= then 1A06:599G<slide$K V <599&5..== print NS+O((, H$H; print NS+O((, chrL<1A06= 2nd If N$ slide5 Hfill buttonfaceH N$ slide5 Hbac-color cyanH N$ slide5 Hline 6 . 6 5..H N$ slide5 Hplace . H;slide5K@% N$ slide5 Hbo4filled 5. H;slide5KG% print N$ slide5t4t3, Int<. 9 V <5.. G slide5K==;HMH If <cset:$ and !riting:.= then 1A0$.:599G<slide5K V <599&5..== print NS+O((, H5H; print NS+O((, chrL<1A0$.= 2nd If N$ slide% Hfill buttonfaceH N$ slide% Hline . 7 $5. 7H N$ slide% Hplace H;slide%JG%;H . ; bo4filled H;slide%J@%;H $EH print N$ slide%t4t3, int<slide%J&$.= 2nd Sub OSuitP

If cset: $ then close NS+O(( close N$ end

Você também pode gostar