Posted: 18 May 2013, 21:30
Wiki page is a start, I guess! I just don't want to spend time telling you stuff you might already know, or could go and learn pretty quickly 
Yup, the Phantom one, which seems to be fairly close to what you want already.
But this...
is surely the most needlessly long-winded way to get the same result as this...
!!!
And in your case, since you want all 8 pins of port B, all you need is...
Initialisation is similarly simplified, since you are setting all the bits...
So that leaves the strobes, which will be a bit of a chore 

Yup, the Phantom one, which seems to be fairly close to what you want already.
But this...
Code: Select all
static uint8_t read_rows(void)
{
return (PINB&(1<<0) ? 0 : (1<<0)) |
(PINB&(1<<1) ? 0 : (1<<1)) |
(PINB&(1<<2) ? 0 : (1<<2)) |
(PINB&(1<<3) ? 0 : (1<<3)) |
(PINB&(1<<4) ? 0 : (1<<4)) |
(PINB&(1<<5) ? 0 : (1<<5));
}
Code: Select all
static uint8_t read_rows(void)
{
return PINB & 0b00111111;
}
And in your case, since you want all 8 pins of port B, all you need is...
Code: Select all
static uint8_t read_rows(void)
{
return PINB;
}
Code: Select all
static void init_rows(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRB = 0;
PORTB = 0xFF;
}
