Go Down

Topic: Newbee and loads of doubts please see (Read 535 times) previous topic - next topic


there is scroller attached for which i am using this i am also attaching the schematic design of the circuit
please help  

this is the basic program i am using to get the leds glow with the moment of the scroller
the input is more like shown below ( has a small phase difference

pin2 ==> __|-|__
pin4 ==> __|-|__

but using this program i am able to capture the the changes and the leds glows
like if i hav led A and led B
so if i have the above input the pins will glow like
like A first and B
and then A and B both r ON
and then just B is ON
what i want is
for the above input that if i get pin2 i want to ignore pin4 and in case the input is lik ethis one
pin2 ==> __|-|__
pin4 ==> __|-|__
i want to ignore the pin2
and i want to use the counter in the program to count the number of inputs that i am getting from the scroller
please help me put

Code: [Select]
#include <avr/io.h>

int main()
  uint8_t i;

  PORTB= 0x00;

/* PB0, PB1 & PB3 are outputs; PB2 & PB4 are scroller inputs */
  DDRB = (1<<PB3) | (1<<PB1) | (1<<PB0);

  PORTB = 0;

  for(;;) {
     i = PINB;

     if ( (i & (1<<PB2)) != 0) {
        PORTB |= (1<<PB0);
     else {
        PORTB &= ~(1<<PB0);

     if ( (i & (1<<PB4)) != 0) {
        PORTB |= (1<<PB1);
     else {
        PORTB &= ~(1<<PB1);
     _delay_us(100); /* wait for a while */


in my mind i had more like a truth table to work on but not able to impliment it
like the input is more like
up ==> 001100
down=> 000110
and in this case i want to ignore the input at the down and send only one out put

pin2 ==> __|-|__
pin4 ==>  __|-|__ for upward moment
if this is the input more like

pin2 ==>  __|-|__
pin4 ==> __|-|__ for downward moment
if this is the input more like

i just want to capture the change in the bit at the signal
and which ever changes first i want to pick that one and niglect the other one

it was suggested by Cliff to use ISR
but i am not able to understand how to intiate this interrupt
if someone can help please

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131