Hi . Please someone assist me, thanks
if I write f6 or ff and read maybe 6 lines. This is the output - 00, 00, f6, f6, 00, 00
Alternates in that pattern
Please what's wrong? Thank you
Moderators note : applied code tags for C
Please use code tags for pieces of code
C:
int da[8] = {22, 23, 24,25,26,27,28,29};
int ad[8] = {36,37,38,39,40,41,42,43};
int we = 2;
int OE = 4;
void set(int a) {
for(int k = -1; k++<7; )
pinMode(ad[k], OUTPUT);
for(int k = -1; k++<7; ) {
digitalWrite(ad[k], (a&1));
a = a>>1;
}
}
void wr(int a, byte b) {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
set(a);
for(int k = -1; k++<7; )
pinMode(da[k], OUTPUT);
for(int k = -1; k++<7; ) {
digitalWrite(da[k], (b&1));
b = b>>1;
}
digitalWrite(2, HIGH);
digitalWrite(2, LOW);
delayMicroseconds(1);
digitalWrite(2, HIGH);
delay(2);
}
byte re(int a) {
set(a);
byte v = 0;
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
for(int k = 8; k-->0; )
pinMode(da[k], INPUT);
for(int k = 8; k-->0; )
v = (v<<1) + digitalRead(da[k]);
return v;
}
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
pinMode(2, OUTPUT);
for(int i = -1; i++<255; ) {
wr(i, 0xf6);
delay(2);
}
for(int f = -1; f++<21; )
Serial.println(re(f), HEX);
}
void loop() {
}
if I write f6 or ff and read maybe 6 lines. This is the output - 00, 00, f6, f6, 00, 00
Alternates in that pattern
Please what's wrong? Thank you
Moderators note : applied code tags for C
Please use code tags for pieces of code