Here is my code
const byte BCD[10][4]={
{0,0,0,0}, //Digit 0
{0,0,0,1}, //Digit 1
{0,0,1,0}, //Digit 2
{0,0,1,1}, //Digit 3
{0,1,0,0}, //Digit 4
{0,1,0,1}, //Digit 5
{0,1,1,0}, //Digit 6
{0,1,1,1}, //Digit 7
{1,0,0,0}, //Digit 8
{1,0,0,1} //Digit 9
};
byte Segments[10][7]={
{1,1,1,1,1,1,0}, //Digit 0
{0,1,1,0,0,0,0}, //Digit 1
{1,1,0,1,1,0,1}, //Digit 2
{1,1,1,1,0,0,1}, //Digit 3
{0,1,1,0,0,1,1}, //Digit 4
{1,0,1,1,0,1,1}, //Digit 5
{1,0,1,1,1,1,1}, //Digit 6
{1,1,1,0,0,0,0}, //Digit 7
{1,1,1,1,1,1,1}, //Digit 8
{1,1,1,1,0,1,1} //Digit 9
};
#define dip_1 13
#define dip_2 A0
#define dip_3 A1
#define dip_4 A2
#define led_1 12
#define led_2 11
#define led_3 10
#define led_4 9
#define led_5 8
#define led_6 7
#define led_7 6
void setup() {
pinMode(dip_1, INPUT_PULLUP);
pinMode(dip_2, INPUT_PULLUP);
pinMode(dip_3, INPUT_PULLUP);
pinMode(dip_4, INPUT_PULLUP);
pinMode(led_1, OUTPUT);
pinMode(led_2, OUTPUT);
pinMode(led_3, OUTPUT);
pinMode(led_4, OUTPUT);
pinMode(led_5, OUTPUT);
pinMode(led_6, OUTPUT);
pinMode(led_7, OUTPUT);
}
void displayDigit(int d) {
digitalWrite(led_1,Segments[d][0]);
digitalWrite(led_2,Segments[d][1]);
digitalWrite(led_3,Segments[d][2]);
digitalWrite(led_4,Segments[d][3]);
digitalWrite(led_5,Segments[d][4]);
digitalWrite(led_6,Segments[d][5]);
digitalWrite(led_7,Segments[d][6]);
}
void loop() {
int D4, D3, D2, D1;
D4=digitalRead(dip_4);
D3=digitalRead(dip_3);
D2=digitalRead(dip_2);
D1=digitalRead(dip_1);
for (int i =0 ; i < 10; i++){
if ( D4==BCD[i][3] and D3==BCD[i][2] and
D2==BCD[i][1] and D1==BCD[i][0])
displayDigit(i);
}
}
It compiles fine fro Arduino Nano. When I compile this simple code on Arduino Uno R4WIFI in the line
D1=digitalRead(dip_1);
I get error
exit status 1
lvalue required as left operand of assignment
Any clues?