08 M2 pin 7 as input.

shamu

Member
Hi all.

I'm having some difficulty reading a button press on input 7 of an 08X2.
This pin also serves as the serial in for programming, is there a command to reconfigure this pin?
Thanks.

Code:
main:
' This is the program for the 08M2 that transmits IR codes.


'dirs =%00000000 All pins inputs.
'dirs =%11111111 All pins outputs.

let dirs = %00000001
#picaxe 08M2
#no_data

SYMBOL Delay = 100

start:

if pinb.1 = 1 then 'Reads b.1 pin 6
  for b0 = 1 to 5
    irout 0,1,10 ' Sends the IR output to C.0 pin 7.
  next b0
end if

if pinc.2 = 1 then  'Reads b.2 pin 5
  for b0 = 1 to 5
    irout 0,1,20
  next b0
end if

if pinc.3 = 1 then 'Reads b.3 pin 4
  for b0 = 1 to 5
    irout 0,1,30
  next b0
end if

if pinc.4 = 1 then 'Reads b.4 pin 3
  for b0 = 1 to 5
    irout 0,1,40
  next b0
end if

if pinc.5 = 1 then 'Reads b.1 pin 2
  for b0 = 1 to 5
    irout 0,1,50
  next b0
end if

goto start
 
Last edited by a moderator:

russbow

Senior Member
All pins on the 08m2 are c.x pins.
if pinb.1 = 1 then 'Reads b.1 pin 6
for b0 = 1 to 5
irout 0,1,10 ' Sends the IR output to C.0 pin 7.
next b0
end if

From your code

You refer to input 7. Do you mean leg 7 whick is out c.0
 
Last edited:

Goeytex

Senior Member
I'm having some difficulty reading a button press on input 7 of an 08X2.
There is no 08x2 and there is no input 7 on a 08M2 I will assume you mean 08M2 and "Leg 7".
Leg 7 is C.0 and cannot be used as an input. It is an output only.

The port on a 08m2 is PortC. (See manual 1 page 10) However code will work using portB naming. You are mixing terms between B and C which makes the code confusing. Probably a good idea to stick with the PortC designators to be consistent.

My guess is that you are having trouble reading input presses on Pinc.5 (Leg 2) which is used for serin. You will likely need to disconnect the programming adapter for this to work depending upon how you have it wired up. A schematic of what you have would be helpful.
 
Last edited:

westaust55

Moderator
PortB or PortC naming can be used for the 08M2.

Goeytex is correct and physical leg/pin 7 which is logical pin C.0 can only be an output.
See PICAXE manual 1 page ~9 for the IO capabilities for each pin.

If it is your last pin and you cannot reassign pins to a comodate the requirements of your project, then if you do a forum search I recall there is a "Kludge" that lows one to determine the state of a signal on pin C.0.

An alternative is also to use a known scheme (another search for you) that allows pin C.3 to be used as an output using a FET (transistor) and the internal -up resistors.

Sorry but not starting a search on iPhone as about to bard an aircraft.
 

shamu

Member
That was a flawedpost!!

The Picaxe is an 08M2
It is input c.5, leg 2, that I'm having trouble reading.
Even with the programming cable disconnected, still no result.

Thanks.
 

westaust55

Moderator
It is input c.5, leg 2, that I'm having trouble reading.
Even with the programming cable disconnected, still no result.
See the disconnect command.
You will need to retain the program in circuit as a pull-down resistor and any switch will then pull the input high.
 

shamu

Member
Disconnect has worked, thanks for the help.
One last thing, the picaxe will now not accept a new download, how can I reset it do that it does?
 

nick12ab

Senior Member
One last thing, the picaxe will now not accept a new download, how can I reset it do that it does?
Turn off the power, make sure that the bulk capacitors are empty, start the download on the computer THEN reapply the power.
 
Top