Rickharris
Senior Member
Having made the thread about grabbing another input for your robot when using a picaxe 08 I though it should be possible at minimal cost to extend the input number to pretty much anything you like (for digital inputs anyway).
In the circuit and code below a picaxe 08 (output 0) is used to clock a 4017 decade counter (a 4017 changes it's outputs every time a clock pulse goes in). The outputs of the counter enable a set of and gates so that the common outputs of the and gates go to pin 3 of the picaxe.
Provided we know which and gate is enabled we can read the state of up to 10 inputs on a single picaxe input.
This works in simulation and on bread board with just 2 inputs.
In the circuit and code below a picaxe 08 (output 0) is used to clock a 4017 decade counter (a 4017 changes it's outputs every time a clock pulse goes in). The outputs of the counter enable a set of and gates so that the common outputs of the and gates go to pin 3 of the picaxe.
Provided we know which and gate is enabled we can read the state of up to 10 inputs on a single picaxe input.
This works in simulation and on bread board with just 2 inputs.
Code:
'picaxe 08 code
'Input extender 4 inputs to pin 3
'uses pin 2 to clock 4017
Start:
for b0=1 to 10 ' input counter
high 0 ' clock to 4017
if pin3=1 then gosub flaginput 'check if input is on otherwise assume it is off
low 0
next b0
goto start
flaginput:
on b0 gosub ip0,ip1,ip2,ip3,ip4,ip5,ip6,ip7,ip8,ip9
' selects the relevant action depending on if the input is on. You would put code here relevant to your application.
return
ip0:
b1=0
return
ip1:
b1=1
return
ip2:
b1=2
return
ip3:
b1=3
return
ip4:
b1=4
return
ip5:
b1=5
return
ip6:
b1=6
return
ip7:
b1=7
return
ip8:
b1=8
return
ip9:
b1=9
return
Attachments
-
18.4 KB Views: 226