void setup() {
// put your setup code here, to run once:
volatile char *dirf, *dirk, *out_dataf, *in_datak, x;
volatile long counter, i;
// directions
dirf = 0x30; dirk = 0x107;
out_dataf = 0x31; in_datak = 0x106;
*dirf = 0x01; *dirk = 0x00;
counter = 0;
while (1) {
x = *in_datak;
if ((x & 0x01) == 0x01) {
counter++;
for (i = 0; i < 100000; i++); // unbounce mechanical button (switch)
}
if (counter % 2) {
*out_dataf = 0x01;
} else {
*out_dataf = 0x02;
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}