OLED serial code.

shamu

Member
Hi all.

I am using an AXE13Y that is fed a message from an 08M2 to display a SIRC code received via infrared.

Now I'm not proud of this but my code looks like:

Code:
'  This program loads into an 08M2 and takes an infrared input on pin 6 then outouts
' it's SIRC value to on OLED conected to pin 7.
#picaxe 08M2
#no_data


SYMBOL infravalue = b10 ; define an infra variable

'let dirs = %10111111  ' Set port C as all outputs.

init:
pause 500

main:


irin C.1, infravalue ; read input C.1 into infravalue
if infravalue = 1 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 1") 
endif
if infravalue = 2 then
 'serout C.0,N2400,("SIRC Code:   ")  
 serout C.0,N2400,("SIRC Code: 2")
endif
if infravalue = 3 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 3")
endif
if infravalue = 4 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 4")
endif
if infravalue = 5 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 5")
endif
if infravalue = 6 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 6")
endif

if infravalue = 7 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 7")
endif
if infravalue = 8 then 
 'serout C.0,N2400,("SIRC Code:   ") 
 serout C.0,N2400,("SIRC Code: 8")
endif
if infravalue = 9 then 
 serout C.0,N2400,("SIRC Code: 9")
endif
if infravalue = 10 then 
serout C.0,N2400,("SIRC Code: 10") 
endif
if infravalue = 11 then 
 serout C.0,N2400,("SIRC Code: 11")
endif
if infravalue = 12 then 
 serout C.0,N2400,("SIRC Code: 12")
endif
if infravalue = 13 then 
 serout C.0,N2400,("SIRC Code: 13")
endif
if infravalue = 14 then 
 serout C.0,N2400,("SIRC Code: 14")
endif
if infravalue = 15 then 
 serout C.0,N2400,("SIRC Code: 15")
endif
if infravalue = 16 then 
 serout C.0,N2400,("SIRC Code: 16")
endif
if infravalue = 17 then 
 serout C.0,N2400,("SIRC Code: 17")
endif
if infravalue = 18 then 
 serout C.0,N2400,("SIRC Code: 18")
endif
if infravalue = 19 then 
 serout C.0,N2400,("SIRC Code: 19")
endif
if infravalue = 20 then 
 serout C.0,N2400,("SIRC Code: 20")
endif

if infravalue = 21 then 
 serout C.0,N2400,("SIRC Code: 21")
endif
if infravalue = 22 then 
 serout C.0,N2400,("SIRC Code: 22")
endif
if infravalue = 23 then 
 serout C.0,N2400,("SIRC Code: 23")
endif
if infravalue = 24 then 
 serout C.0,N2400,("SIRC Code: 24")
endif
if infravalue = 25 then 
 serout C.0,N2400,("SIRC Code: 25")
endif
if infravalue = 26 then 
 serout C.0,N2400,("SIRC Code: 26")
endif

if infravalue = 27 then 
 serout C.0,N2400,("SIRC Code: 27")
endif
if infravalue = 28 then 
 serout C.0,N2400,("SIRC Code: 28")
endif
if infravalue = 29 then 
 serout C.0,N2400,("SIRC Code: 29")
endif

if infravalue = 30 then 
 serout C.0,N2400,("SIRC Code: 30")
endif

if infravalue = 31 then  
 serout C.0,N2400,("SIRC Code: 31") 
endif
if infravalue = 32 then 
 serout C.0,N2400,("SIRC Code: 32")
endif
if infravalue = 33 then 
 serout C.0,N2400,("SIRC Code: 33")
endif
if infravalue = 34 then 
 serout C.0,N2400,("SIRC Code: 34")
endif
if infravalue = 35 then 
 serout C.0,N2400,("SIRC Code: 35")
endif
if infravalue = 36 then 
 serout C.0,N2400,("SIRC Code: 36")
endif

if infravalue = 37 then 
 serout C.0,N2400,("SIRC Code: 37")
endif
if infravalue = 38 then 
 serout C.0,N2400,("SIRC Code: 38")
endif
if infravalue = 39 then 
 serout C.0,N2400,("SIRC Code: 39")
endif
if infravalue = 40 then 
 serout C.0,N2400,("SIRC Code: 40") 
endif

if infravalue = 41 then  
 serout C.0,N2400,("SIRC Code: 41") 
endif
if infravalue = 42 then 
 serout C.0,N2400,("SIRC Code: 42")
endif
if infravalue = 43 then 
 serout C.0,N2400,("SIRC Code: 43")
endif
if infravalue = 44 then 
 serout C.0,N2400,("SIRC Code: 44")
endif
if infravalue = 45 then 
 serout C.0,N2400,("SIRC Code: 45")
endif
if infravalue = 46 then 
 serout C.0,N2400,("SIRC Code: 46")
endif

if infravalue = 47 then 
 serout C.0,N2400,("SIRC Code: 47")
endif
if infravalue = 48 then 
 serout C.0,N2400,("SIRC Code: 48")
endif
if infravalue = 49 then 
 serout C.0,N2400,("SIRC Code: 49")
endif
if infravalue = 50 then 
 serout C.0,N2400,("SIRC Code: 50") 
endif
Surely there must be an easier way to display the content of a variable, something like:
serout C.0,N2400,"SIRC value is:";infravalue

Thanks.
 

jims

Senior Member
This should do what you described. Be aware that data from the numeric keypad. is offset & may need to be corrected if you want it to match the symbols on the keys. Jims



Code:
'  This program loads into an 08M2 and takes an infrared input on pin 6 then outouts
' it's SIRC value to on OLED conected to pin 7.
#picaxe 08M2
#no_data


SYMBOL infravalue = b10 ; define an infra variable

'let dirs = %10111111  ' Set port C as all outputs.

init:
pause 500

main:

	do
	 serout C.0,N2400,(254,1)
	 irin C.1, infravalue ; read input C.1 into infravalue
	 serout C.0,N2400,(254,128,"SIRC Code:   ",#b10)
	 pause 1000	'Pause to see OLED.
	loop
 
Top