void setup() {
// put your setup code here, to run once:
volatile char *dirf,*dirk,x;
volatile char *outf,*ink;
dirf = 0x30; dirk = 0x107;
outf = 0x31; ink = 0x106;
*dirf = 0x01; *dirk = 0x00;
while(1){
x = *ink;
if((x & 0x01) == 0x01){
*outf = 0x01;
}
else{
*outf = 0x00;
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}
/*
code with typecasting...........................
void setup() {
// put your setup code here, to run once:
volatile char *dirf, *dirk, *outf, *ink;
volatile char x;
// Assigning addresses to the pointers
dirf = (volatile char *)0x30;
dirk = (volatile char *)0x107;
outf = (volatile char *)0x31;
ink = (volatile char *)0x106;
// Setting direction registers
*dirf = 0x01; // Set dirf to output
*dirk = 0x00; // Set dirk to input
while(1) {
x = *ink; // Read input
if((x & 0x01) == 0x01) { // Check if the first bit is set
*outf = 0x01; // Set output
} else {
*outf = 0x00; // Clear output
}
}
}
void loop() {
// put your main code here, to run repeatedly:
} */