Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic 16f877a multiplex display

Status
Not open for further replies.

taljen

Newbie level 3
Joined
Jul 26, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
i want to display 00000110 in DIS0 and 01000000 in the rest( depending on the pressing of a button where specifically)
how can i do this?
does anyone know of an example in any website similar to a ping pong game????this is what i am really tying to do...
thanks a lot!!
 

you post is a little bit confusing for me basically i understand it as,
you want to display 6 in DIS0 and want to display 64 in DIS1,DIS2, DIS3, DIS4, DIS5, DIS6, DIS7.(rest).
where you want to display these digits> want to display them seven segment OR LCD?....

by pushing the button the controller will enter in the loop from dis0 to dis7 when you release the button it will select one of the DIS and display it on LCD or seven segment?
 

you post is a little bit confusing for me basically i understand it as,
you want to display 6 in DIS0 and want to display 64 in DIS1,DIS2, DIS3, DIS4, DIS5, DIS6, DIS7.(rest).
where you want to display these digits> want to display them seven segment OR LCD?....

by pushing the button the controller will enter in the loop from dis0 to dis7 when you release the button it will select one of the DIS and display it on LCD or seven segment?

sorry i didnt explain myself good enough...
basically in the game there are two rackets one on each side of the segment display and the ball is the line of the middle of the sgement display that keeps moving between all of them..
when we press button X we see racket A (the two vertical lines in one of the ends) and when we press button Y we see racket B (the two vertical lines in the other end) and the ball we see continously moving back and forward...
my problem is that i can see the rackets but i cant see the ball moving ... here is my code and highlighted are the lines where i think is the problem but i dont understand why it is a problem and where should i put this lines...

- - - Updated - - -

sorry i forgot to put the code this is it:
void interrupt() {

if (flag == 0)
{
if (displayA)
{
PORTA = 0;
PORTD = raquetA;
PORTA = 1;
}
if (displayB)
{
PORTA = 0;
PORTD = raquetB;
PORTA = 8;
}
flag = 1;
}

else
{

PORTA = 0; // Turn off all 7seg displays
PORTD = ball; // send mask for ball to PORTD
PORTA = counter; // turn on 7seg displays
flag = 0;
timerCount++;
if(direction==0 && timercount==20)
counter = counter * 2;
else if(timercount==20)
counter = counter / 2;
}

if (counter == 8 && displayB)
direction = 1;
else if (counter == 1 && displayA)
direction = 0;

TMR0 = 0; // clear TMRO
INTCON = 0x20; // clear TMR0IF and set TMR0IE
}

void main() {
OPTION_REG = 0x80; // Timer0 settings
TMR0 = 0; // clear TMRO
INTCON = 0xA0; // Disable PEIE,INTE,RBIE,T0IE
PORTA = 0; // clear PORTA (make sure both displays are off)
TRISA = 0; // designate PORTA pins as output
PORTD = 0; // clear PORTD (make sure LEDs are off)
TRISD = 0; // designate PORTD pins as output
PORTB = 0;
TRISB = 0xFF;
counter = 1;
ball = 0x40;
raquetB = 0x30;
raquetA = 0x06;
flag = 0;
oldstateB = 0;
oldstateA = 0;
displayB = 0;
displayA = 0;
counter = 1;
checkA = 1;
checkB = 1;
timercount= 0;
do
{

if (checkA == 1)
{
if (Button(&PORTB, 0,0,1) )
{
displayA = 1;
delay_ms(400);
displayA = 0;
checkA = 0;
oldstateA = 1;
}
}
if (checkB == 1)
{
if (Button(&PORTB, 7,0,1) )
{
displayB = 1;
delay_ms(400);
displayB = 0;
checkB = 0;
oldstateB = 1;
}
}


if( oldstateA && Button(&PORTB, 0,0,0))
{
oldstateA = 0;
checkA = 1;
}


if( oldstateB && Button(&PORTB, 7,0,0))
{
oldstateB = 0;
checkB = 1;
}

}
while(1);
// endless loop
}
 

sorry i didnt explain myself good enough...
basically in the game there are two rackets one on each side of the segment display and the ball is the line of the middle of the sgement display that keeps moving between all of them..
when we press button X we see racket A (the two vertical lines in one of the ends) and when we press button Y we see racket B (the two vertical lines in the other end) and the ball we see continously moving back and forward...
my problem is that i can see the rackets but i cant see the ball moving ... here is my code and highlighted are the lines where i think is the problem but i dont understand why it is a problem and where should i put this lines...

- - - Updated - - -

sorry i forgot to put the code this is it:
void interrupt() {

if (flag == 0)
{
if (displayA)
{
PORTA = 0;
PORTD = raquetA;
PORTA = 1;
}
if (displayB)
{
PORTA = 0;
PORTD = raquetB;
PORTA = 8;
}
flag = 1;
}

else
{

PORTA = 0; // Turn off all 7seg displays
PORTD = ball; // send mask for ball to PORTD
PORTA = counter; // turn on 7seg displays
flag = 0;
timerCount++;
if(direction==0 && timercount==20)
counter = counter * 2;
else if(timercount==20)
counter = counter / 2;
}

if (counter == 8 && displayB)
direction = 1;
else if (counter == 1 && displayA)
direction = 0;

TMR0 = 0; // clear TMRO
INTCON = 0x20; // clear TMR0IF and set TMR0IE
}

void main() {
OPTION_REG = 0x80; // Timer0 settings
TMR0 = 0; // clear TMRO
INTCON = 0xA0; // Disable PEIE,INTE,RBIE,T0IE
PORTA = 0; // clear PORTA (make sure both displays are off)
TRISA = 0; // designate PORTA pins as output
PORTD = 0; // clear PORTD (make sure LEDs are off)
TRISD = 0; // designate PORTD pins as output
PORTB = 0;
TRISB = 0xFF;
counter = 1;
ball = 0x40;
raquetB = 0x30;
raquetA = 0x06;
flag = 0;
oldstateB = 0;
oldstateA = 0;
displayB = 0;
displayA = 0;
counter = 1;
checkA = 1;
checkB = 1;
timercount= 0;
do
{

if (checkA == 1)
{
if (Button(&PORTB, 0,0,1) )
{
displayA = 1;
delay_ms(400);
displayA = 0;
checkA = 0;
oldstateA = 1;
}
}
if (checkB == 1)
{
if (Button(&PORTB, 7,0,1) )
{
displayB = 1;
delay_ms(400);
displayB = 0;
checkB = 0;
oldstateB = 1;
}
}


if( oldstateA && Button(&PORTB, 0,0,0))
{
oldstateA = 0;
checkA = 1;
}


if( oldstateB && Button(&PORTB, 7,0,0))
{
oldstateB = 0;
checkB = 1;
}

}
while(1);
// endless loop
}

i no longer need help i managed thanks anyways
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top