ࡱ> u@ 4bjbj `{[!T/T/T/8/4/[00(000MMM[[][][][][][][$\R$_[MLMMM[00?[XXXM"00[[XM[[XBXXx@X00 xT/PXY[0[X_U_X_XMMXMMMMM[[! X!Using PICAXE with Inputs You can also use inputs with a PICAXE. Here we use a simple top switch block. The switch is in a potential divider circuit so that the output of the block is normally held low (zero), but when the switch is pressed the blocks output goes high (one). You can test this with the PICAXE. The switch is on input pin 1. main: if input1=1 then light if switch pressed jump low 4 make sure LED is off goto main do it again light: high 4 new label turn LED on goto main check switch again Here is another program which flashes a different LED depending on whether the switch is pressed. main: if input1=1 then flash1 jump if input is high high 7 output 7 on goto flash7 flash1: high 1 output 1 on flash7: pause 200 wait 0.2 seconds let pins=%00000000 turn all outputs off pause 200 wait 0.2 seconds goto main jump back to start Using the 7 segment display can you create a circuit which counts the number of times the switch is pressed? Here is the first part: init: symbol count = b0 set up an alias count = 0 start count at zero main: if input1 = 1 then add1 jump if key pressed pause 50 give key time to settle ... you do the rest!  Using Analog Inputs You can use standard sensor blocks with any PICAXE input, perhaps using a comparator to set the switching level. However a PICAXE 18 has analog inputs on pins 0, 1 and 2. Connecting directly to the core block will use pin 1. If you put the sensing block before one of the 4 key units then the input will be on pin 2. main: readadc 1,b0 'read input 1 into b0  debug b0 'send value to computer b1=b0/20 'change into 8 levels if b1<8 then skip b1=7 skip: let pins=0 'turn current LED off high b1 'show value on 8 LEDs goto main The following code reads the light sensor on pin 2 and displays the result on the LCD display. Analog input is low resolution for PICAXE18 and high resolution for 18A. init: pause 500 main: readadc 2,b1 serout 4,N2400,(254,128,"Input 2 is ",#b1," ") 'show number pause 200 goto main This code takes an analog input and displays it as 8 levels on LEDs. main: readadc 1,b0 'read input 1 into variable b0 debug b0 'check value on computer b1=b0/20 'change into 8 levels if b1<8 then skip b1=7 skip: let pins=0 'turn current LED off high b1 'show value on 8 LEDs goto main This program sets two LEDs according to the analog input. main: readadc 1,b0 'read channel 2 into variable b0 debug b0 if b0 > 90 then top 'if b0 > 90 then do top if b0 < 50 then bot 'if b0 < 50 then do bot low 1 'else switch off 1 low 2 'and switch off 2 goto main 'jump back to the start top: high 1 'switch on 1 low 2 'switch off 2 goto main bot: high 2 'switch on 2 low 1 'switch off 1 goto main Instead of an LDR you could use a thermistor or potentiometer input. Using the DS18B20 Temperature Sensor This Dallas One-Wire sensor provides the temperature in degrees centigrade when interrogated by the PICAXE ReadTemp instruction. Here is a simple example displaying the result on an LCD screen. The pcb passes 4 inputs through to a preceding block. loop: pause 500  readtemp 1,b1 if b1>127 then neg serout 4,N2400,(254,128,"Temp is ",#b1," ") goto loop neg: let b1=b1-128 serout 4,N2400,(254,128,"Temp is ","-",#b1," ") goto loop Using an Infra-red Remote Control  You can use a TSOP1836 device to receive signals from an ordinary remote control. As long as it uses the standard RC5 coding system then the Picaxe can understand it using Infrain and Infra commands. The first program turns LEDs on and off depending on which keys on the remote are pressed. The pcb looks more complicated than it is really because it passes through 4 of the inputs. loop: infrain always uses pin 0 if infra = 1 then swon1  if infra = 2 then swon2 if infra = 3 then swon3 if infra = 4 then swoff1 if infra = 5 then swoff2 if infra = 6 then swoff3 goto loop swon1: high 1 goto loop KeyValue112233445566778899P+10011V+12P-1310+14V-15Mute16Power17swon2: high 2 goto loop swon3: high 3 goto loop swoff1: low 1 goto loop swoff2: low 2 goto loop swoff3: low 3 goto loop This program takes the key press and displays it on an LCD display. It would need extending to display more keys. init: pause 500 loop: let pins=0 clear outputs infrain if infra = 1 then swon1 if infra = 2 then swon2 if infra = 3 then swon3 goto loop swon1: high 1 serout 4,N2400,(254,128,"Key pressed ",#1," ") goto loop swon2: high 2 serout 4,N2400,(254,128,"Key pressed ",#2," ") show number goto loop swon3: high 3 serout 4,N2400,(254,128,"Key pressed ",#3," ") goto loop The next program uses the P+ and P- keys (along with V+ and V-) to set the level of two variables and display them on the LCD. symbol P = b0 symbol V = b1 init: pause 500 'allow LCD to initialise serout 4,N2400,("Ready") P=50 'initial value set half way V=50 main: infrain if infra=10 then increaseP 'P+ if infra=13 then decreaseP 'P- if infra=12 then increaseV 'V+ if infra=15 then decreaseV 'V- goto main increaseP: if P=100 then display '100 is max possible value P=P+1 goto display decreaseP: if P=1 then display '1 is minimum value P=P-1 goto display increaseV: if V=100 then display V=V+1 goto display decreaseV: if V=1 then display V=V-1 display: serout 4,N2400,(254,128,"P is set at ",#b0," ") serout 4,N2400,(254,192,"V is set at ",#b1," ") goto main  FILENAME 3 Using PICAXE with Inputs.doc www.school-electronics.co.uk page  PAGE 4 330R 4k7 TSOP 1840 DS18B20 Z v   r v  & 1 G e { ͻ͚͈zhaWaWhfhf5>* hy^5>*#hfhf5CJOJQJ^JaJjhfUmHnHu#he_hf5CJOJQJ^JaJ#hEhf5CJOJQJ^JaJhf5CJOJQJ^JaJ#hPhf5CJOJQJ^JaJhfCJaJh.h.hB5>*CJ aJ h.h.5>*CJ aJ hl5>*CJ aJ "Z   r 8 V v w ' !!s!.j!.j!.j!.j!.j!s!s!.j!.j!.j!.j!.j!.j!.j!.j!s!s!.j j^jgdf jx^jgdf j^jgdf kx^kgdf  gdf3' H |  6Yy!.j!.j!.j!.j!.j!!!!1!1!1!1!1!1!1!1!!!!1!1!1!1!1!gdMgd. j^jgdf p q 67BFMOPRFM`a5pq.1NPwy12ٯhfhPY4CJOJQJ^JaJ hPY4hPY4CJOJQJ^JaJhPY4hDCJOJQJ^JaJ hMhMCJOJQJ^JaJ hMhMhMhDjhY_bUmHnHtH uh. h.h.hf7LM *56pq 'Chi!!!1!1!1!1!1!1!1!1!!!!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1gdPY4gdM23YZUVfv68*D^x!1!!!!!1!1!1!1!1!1!1!!!!!1!1!1!1!1!1!1 @gd|1egd:NgdPY4234?BCXYTUVfg678LN\ǶǕ|x|gYghI>CJOJQJ^JaJ h|1eh:NCJOJQJ^JaJhMh|1e hWh:NjhWUmHnHuh:Nh:N5>*,jhf5>*CJ UaJ mHnHtH u h:Nh:NCJOJQJ^JaJh:NhW h:Nh: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Vl t 6Pu"655Yp$$If!vh55Y#v#vY:Vl t 6Pu"655Yp$$If!vh55Y#v#vY:Vl t 6Pu"655Yp$$If!vh55Y#v#vY:Vl t 6Pu"655Yp$$If!vh55Y#v#vY:Vl t 6Pu"655Yp$$If!vh55Y#v#vY:Vl t 6Pu"655YL@L Normal$CJOJQJ^J_HaJmH sH tH DA@D Default Paragraph FontRi@R  Table Normal4 l4a (k(No Liste@ .HTML Preformatted7 2( Px 4 #\'*.25@9CJOJQJ^JaJmH sH 4@4 pHeader  !4 @4 pFooter  !.)@!. p Page Numberj@3j J Table Grid7:V0  4kjiw  #4`Zr 8Vvw'H|  6YyLM * 5 6 p q ' C h i 2 3 Y Z U V f v    6 8 *D^x  $/?JYds~  AJd}=HX%45a{6AB~6>?x"'(012500p0000000000000000000000000p0p00p0p0p0p00000000000000000000000000000 00 00 000000000000000x00x000000000000x0x0 00 00 00 00 000 0 0 @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ @0Y @0Y @0\ 00 00 000000000000000000000000 00 0 0 0000000000000000 00 00 00 00 00 00000000 @0@00@00000H000000 Zr 8VvH| * 2 3 Y Z f    6 8   ds~=>?x5O900O900@0|0 0|0 0|0 0|0 0@0|0 0|0 0|0 0|0 0|0 0@0@0M900(UM900M900@0O900TpO900O900O900O900O900O900 xL O900O9000@0O90 0 x9O90 0O90 00@0O900 O900O9000<00<00<00<000X0X@0O900kO900O9000X0XO90"0O90#0@0@0|00fLF|6 |00d |00 |00d |00 |00d r|00 |00d r|00 |0 0d r|00 |0 0d r|00 |00d r|00 |00d r|00 |00d r|00 |00d r|00 |00d r|00 |00d r|00 |00d r|00 |00d r|00 |00d r|00 |00f|00 F6 |00 |00 F6Oy0#0O90#0O90#00X@0<0Q0<0Q0<0Q0<0/0<0/0O90V0\,SUM90V0M90V0<0/00ZZZ] 2<4,/' x a4 !"#$%&'()*+-.3 *NUW]!Ob$TM7X"'D(    S A http://www.electronics.pwp.blueyonder.co.uk/picaxe2_files/image018.gif"`P  # A#" `P  # A#" `  b  I L #" 6 Z f M f"t M 1  N# #" -)n "M 1  O #" M 1 TB P C D" [  TB Q C D[M [1  TB R C DM 1  TB S C D   TB T C Dsw w  TB U C DM   t  V# #" Efpt " W# L#" {B4 X 3" TB Y C D3 TB Z C D fB [ s *DrRr TB \ C D TB ] C D fB ^ s *D0 TB _ C Drs fB ` s *DBr pt " a# L#" B4 b 3" TB c C D3 TB d C D TB e C DBr TB f C D TB g C D fB h s *D N i  R. h j 3 "`eI h k 3 "` e lb e9X  l #" 4 m s TB n C Dg9gs TB o C DggX  TB p C D pt " q# L#" /4 r 3" TB s C D3 TB t C D fB u s *D TB v C D9 h w 3 "`esg b  m x #" pt " y# L#" ` 4 z 3"TB { C D3TB | C Dn    } #"  dt ^ ~C# #" D  lB  0LD]^lB  0D<n   #"  D 4  RvoTB  C D@i@TB  C D@@OP2   "`4n x  #" `  m4  xRlB  0LD=CoTB  C D??TB  C D?R?xB  <D  B S  ?63 f 6 4! Txsdt+ @ Tl]!t  TL4=r!@tW[SZ+ / w ~  D H h p y}%)@DZ^txAH>BY_bh(17;BK  HNz25Z^rv9>W[(-HL} 8=z|MQ  + / q u  ( + D H i l V Z h p w y be+-EG_ay}%)@DZ^tx #AHKMeg~>BY_&,59bh7;BK  ?Fz25333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333367BFMOPR`a  q q   . 1 N P w y f g v v   8 8 L N //JJYYdd  %AJJ0<(01255 C J LeighChristopher Leigh! 0u fL.PY4:I>B:NR"T Xy^Y_b|1ef'{,p! MwjK[4MDWJ+l  5@h4@@UnknownGz Times New Roman5Symbol3& z Arial?5 z Courier New"1h{3|=z '=z '!4d3QH)?:Using PICAXE with Analog Inputs C J LeighChristopher LeighOh+'0 0< X d p | Using PICAXE with Analog Inputssin C J LeighXE J  J  Normal.dotEChristopher LeighAn26iMicrosoft Word 10.0@u#@@S@LI=z՜.+,D՜.+,\ hp  Dean Close Schoole' {  Using PICAXE with Analog Inputs Title 8@ _PID_HLINKSA:FGhttp://www.electronics.pwp.blueyonder.co.uk/picaxe2_files/image018.gif  !"#$%&'()*+,-./0123456789:;<=?@ABCDEGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuwxyz{|}Root Entry FЬData >1TableF_WordDocument`{SummaryInformation(vDocumentSummaryInformation8~CompObjj  FMicrosoft Word Document MSWordDocWord.Document.89q