20x2 4 digit 7 segment UP dn counter with memory

marks

Senior Member
the up and dn button is read through the adc returning a value
up = 6 count up to (9999)
dn= 7 or countdown
normal status =8 no button pressed
both pressed =3 allows to zero count ( 0)
power <5v =9 allowing number to be writen to eeprom when power turned off

note may require a supply that drops off slowly i use a 12v plugpack feeding a 5v regulator
( the 12v holds up for a couple of secs)

if using standard picaxe 5v regulated supply should work ok

if using a battery add a 100uf capacitor across picaxe supply pins 1 and 20(if u dont already hav 1 lol)
for reliable write to eeprom operation should work ok lol.
a voltage between 5 and 5.4 is required for lower voltages different adc values wil be required

ie.for voltage between 4.6 and 4.9 approx change value 3 to 4 (both buttons pushed) others ok
ie.for lower voltages 4.6 vref of tl431 would have to be changed also


Code:
        '             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- --   -- --   -- --   
	'
	'Display        1       2       3       4
	'Common anode  C.3     C.2     C.1     c.0
	
	 
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255)     'character (0,1,2,3,4,5,6,7,8,9,blank)

SETFREQ M16
	
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	
	SYMBOL character = B10	
	SYMBOL number     = W1
	SYMBOL bounce     = W2
	SYMBOL pushbutton = W3
	
let dirsb = %11111111
let dirsc = %00111111	
	
main: read 22,word number
start:bounce = 0
Display:	
	character = 10 : IF number < 1000 THEN dig1                             'Display1 Zero blanking	
      LET character = number DIG 3                                       
    Dig1:  READ character,pinsb :                   LOW display1 : PAUSE 1 : HIGH display1      
 
                       IF number < 100  THEN dig2                             'Display2 Zero blanking
	LET character = number DIG 2 	                                          
    Dig2:  READ character,pinsb :                   LOW display2 : PAUSE 1 : HIGH display2  	
	
	                 IF number < 10   THEN dig3                             'Display2 Zero blanking
	LET character = number DIG 1			
    Dig3:  READ character,pinsb :                   LOW display3 : PAUSE 1 : HIGH display3  
		
	LET character = number DIG 0 	                                                              
    Dig4:  READ character,pinsb :                   LOW display4 : PAUSE 1 : HIGH display4 
    
    readadc10 c.7,pushbutton let pushbutton= pushbutton/100                   'check pushbutton status
    
    if pushbutton =8  then start                                              'no buttons pressed                                    
    if pushbutton =3 then let number = 0 :endif                               'both buttons pressed will zero number
    
inc bounce                                              
if bounce >1 then display


if pushbutton =6 then IncrementCounter                                        ' Up button pressed
if pushbutton =7 then DecrementCounter                                        ' Dn button pressed
if pushbutton =9 then Remember                              ' Detects voltage <5v when powered off

IncrementCounter:
inc number
if number=10000 then : number = 0 :endif
goto display

DecrementCounter:
dec number
if number=65535 then : number = 9999 :endif
goto display

Remember:
write 22,word number
goto display
 

Attachments

Last edited:

raul1958

Member
Hi Marks,
I would ask you something.........!!
this project is fantastic but I need to see into the 2X16 LCD ( NO SERIAL), not into the 4 digit 7 segment .... CAN YOU HELP ME..??????
I am novice for the PICAXE comand.....
SORRY for my english....is very bad..I speak only ITALIAN and SPANISH languages......THANK YOU .....!!
 

Jamster

Senior Member
raul, a paralell LCD is something completly different, have a look in manual 3 (page 37 to 40) and there is code there to get you started.
Also, post in your natural language and we can use Google to translate.

Italian using google translate:
Raul, un parallelo LCD è qualcosa di completamente diverso, uno sguardo in manuale 3 (pagina 37 a 40) e non vi è il codice lì per cominciare.
Inoltre, posta nella tua lingua naturale, e possiamo utilizzare Google per tradurre.
 

raul1958

Member
raul, a paralell LCD is something completly different, have a look in manual 3 (page 37 to 40) and there is code there to get you started.
Also, post in your natural language and we can use Google to translate.

Italian using google translate:
Raul, un parallelo LCD è qualcosa di completamente diverso, uno sguardo in manuale 3 (pagina 37 a 40) e non vi è il codice lì per cominciare.
Inoltre, posta nella tua lingua naturale, e possiamo utilizzare Google per tradurre.
OK .. thanks Jamster!
excuse my ignorance on the subject, but where is the "manuale3"?
I did not use the translator of google because you do not understand anything when doing the translation.
It seems that they all speak in INDIAN ...!! Hi. Hi. Hi ....!!!
Thanks again .....
RAUL

I forgot ...
I know that things are different these types of displays, I use very often but I never ever programmed in BASIC PICAXE ....!! and I'm missing some commands ....
You can help me ????
 
Last edited:

nick12ab

Senior Member
You'll find Manual 3 on the Help menu of PICAXE Programming Editor but their circuit uses 4-bit mode which is OK if you've got plenty of program memory left. Code is provided for that.

I also recommend looking through an LCD datasheet for full details on initializing and using it.
 

raul1958

Member
You'll find Manual 3 on the Help menu of PICAXE Programming Editor but their circuit uses 4-bit mode which is OK if you've got plenty of program memory left. Code is provided for that.

I also recommend looking through an LCD datasheet for full details on initializing and using it.
Problem solved ... the code works ok ...... NO MANUAL USE.....!! Hi..Hi..!!
 
Top