uint8_t cyc_time;
uint16_t micr1;
uint8_t debor0;
uint8_t deband1;
uint8_t inmem[6];
uint8_t debregs[6];
void setup() {
// put your setup code here, to run once:
DDRB=63;
DDRD=0;
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
cyc_time += 10;
uint16_t micr0=micros();
//debounce
for(uint8_t i=4;i>=0;i--){
debregs[i+1]=debregs[i];
}
debregs[0]=PIND;
debregs[0]=debregs[0] >> 2;
debor0=0;
deband1=255;
for(uint8_t i=0;i<6;i++){
debor0 |= debregs[i];
deband1 &= debregs[i];
}
for(uint8_t i=0;i<6;i++){
if(debor0 &1==0){inmem[i]=0;}
if(deband1 &1==1){inmem[i]=1;}
debor0 = debor0 >> 1;
deband1 = deband1 >> 1;
}
//------------- wait for the end of the cycle ----------------
uint8_t i = 0;
while (i == 0)
{
if ( ((uint8_t)millis() == cyc_time) ) {
i = 1;
}
if ( ((uint8_t)millis() == cyc_time + 1) ) {
i = 1;
}
}
//------------------------------------------------------------
}