Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hello all!!!

Status
Not open for further replies.

Mama Sumae

New Member
Hello all !!! been a guest for quite a while now but have def join today since like any other microcontroller noob a time comes when u decide to bug the superior minds ;) with some basic random questions that they answered 5 times in the same day alone.
Do u mind if i go straight to business now? ok then made this basic circuit in proteus that believe it or not i designed (only to find thousands like this one online :confused: guess there isnt much to it anyway) and loaded some basic codes using MPLAB.


https://img258.imageshack.us/my.php?image=circuitbe0.png (circuit have a look and admire my noob skills)

All fine till here since i have some electronics background but then assembly came to place and i found myself lost... C++ is ok to me but assembly is way beyond my knowledge. So I am capable of loading some random numbers to the 7 segment display by manually creating the output example:
To make 3 I use:

myPortB equ 0x06

org 0x000

start movlw 0x00
tris myPortB

movlw b'10011110'
movwf myPortB

circle goto circle ; done

end


What I want to do is a circuit that outputs the input number in the seven segment display, so if switch 1 is pressed a 1 should appear on the display and if switch 4 is pressed a 4 appears. Pretty simple I would reckon but I seem to be lost in the endless internet resources and every single site seems to use different statements in the code making it impossible for me to understand and use them to my own benefit.

Guess it should be something pretty boring to u guys but also something pretty easy and fast to do so can a kind soul provide me with some enlightenment with this.

ohh and between this i am using the PIC16F84A since i have one somewhere arround here.
 
To use your example code,
Code:
circle		btfsc	PORTA,0		;S1 pressed
		movlw	b'01010101'	;set pattern for S1
		btfsc	PORTA,1		;S2 pressed
		movlw	b'10101010'	;set pattern for S2
	; repeat for other keys
		movwf	PORTB		;write pattern to port
		goto	circle		;go and do it all over again

You should be able to get something working with the above.

You should then work your way through some of the tutorials mentioned in the sticky.

Mike.
 
Real thanks it worked great.... still in process of learning assembly, currently reading Nigel's tutorials and contrary to what i expected my c experience doesnt help much.

Just one more question although working great the output only stays on the 7 segment display while the switch is pressed how can i make it so that once one of the switches is pressed the output reflects it permanently, meaning that the circuit will only output the value of the first pressed switch and ignore all the others.



My current code:
**************************
list p=16F84A
radix hex


myPortA equ 0x05
myPortB equ 0x06


org 0x000
movlw 0x00 ; load W with 0x00 make port B output
tris myPortB ; copy W tristate to port B output

movlw 0xFF ; load W with 0xFF make port A input
tris myPortA ; copy W tristate to port A

movlw b'0000'
movwf myPortA

btfsc myPortA,0 ;S1 pressed
movlw b'00001100' ;set pattern for S1
movwf myPortB ; write W value to port B LEDs

btfsc myPortA,1 ;S2 pressed
movlw b'10110110' ;set pattern for S2
movwf myPortB ; write W value to port B LEDs

btfsc myPortA,2 ;S3 pressed
movlw b'10011110' ;set pattern for S3
movwf myPortB ; write W value to port B LEDs

btfsc myPortA,3 ;S4 pressed
movlw b'11001100' ;set pattern for S4

movwf myPortB ; write W value to port B LEDs


end
************************************
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top