serin issue

Jaden

Senior Member
Hoping this is just a doh! issue. I run the Simulator in the Picaxe programming editor and I can get C.0 and B.2 to go high but not the others! Cannot work out why. I am using a 14M2

Thanks

Code:
' PICAXE-14M2
 ' Serinhandle.bas
  
 Symbol status = b20
 

main:

	serin C.5,N2400, status					
	
	if status = %01000000 then high C.0 		
	endif
	if status = %00100000 then high C.4		
	endif
	if status = %00001000 then high C.2		
	endif
	if status = %00000100 then high C.1		
	endif
	if status = %00000010 then high B.1		
	endif
	if status = %00000001 then high B.2 		
	endif

	pause 1000
	let pinsC = %00000000
	pause 200
	let pinsB = %00000000
	
	
	goto main
 

eclectic

Moderator
Hmmm?

Just downloaded and tried your code,
with a very minor modification.

Code:
#picaxe 14m2
  
 Symbol status = b20 
main:
 serin C.5,N2400, status     
 
 if status = %01000000 then high C.0   
 endif
 if status = %00100000 then high C.4  
 endif
 if status = %00001000 then high C.2  
 endif
 if status = %00000100 then high C.1  
 endif
 if status = %00000010 then high B.1  
 endif
 if status = %00000001 then high B.2   
 endif
 pause 1000
 let pinsC = %00000000
 pause 200
 let pinsB = %00000000
 
 
 goto main


Works here using
1, 2, 4, 8, 32, 64

e
 
Last edited:

Jaden

Senior Member
Thanks for that electic I will try the code in VSM and see what happens, I have tried the Picaxe programming editor tell it the chip is a 20M2 and still the same results.
 

Goeytex

Senior Member
Here's another way to do the exact same thing using "Select Case". A bit neater than all the "ifs" and "end ifs".
This simulates fine in PE.

Code:
#PICAXE 14M2   'Define Picaxe Chip for Editor/ Compiler   
 
symbol status = b20
 main:
   	 serin C.5,N2400, status	
	
	 select case status
	
	    case %01000000 : high C.0
	    case %00100000 : high C.4	
	    case %00001000 : high C.2					
	    case %00000100 : high C.1	
	    case %00000010 : high B.1
	    case %00000001 : high B.2 
	
	end select 
	
	pause 1000
	let pinsC = %00000000
	pause 200
	let pinsB = %00000000
	
goto main
 

hippy

Ex-Staff (retired)
Thanks for that electic I will try the code in VSM and see what happens, I have tried the Picaxe programming editor tell it the chip is a 20M2 and still the same results.
Make sure you have the latest Programming Editor - As with eclectic, your program simulates as expected for me.

It doesn't really make sense to me to try VSM or to tell the Programming Editor it's a different chip to what you are using and the code is written for. That's trying to side-step the problem rather resolving whatever the problem is.
 
Top