I tried the below program but it didnt work. I want to get the CurrentInPin [4] array in serial monitor if there is any change batween PreviousinPin [4] array and CurrentInPin [4] array.
int IN1=4;
int IN2=5;
int IN3=6;
int IN4=7;
int PreviousInPin [4];
int CurrentInPin [4];
int i;
int j;
int new_sensorValue1;
int new_sensorValue2;
int new_sensorValue3;
int new_sensorValue4;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
pinMode (4, INPUT_PULLUP);
pinMode (5, INPUT_PULLUP);
pinMode (6, INPUT_PULLUP);
pinMode (7, INPUT_PULLUP);
Serial.print ("PrevoiusInPin [4]=");
Serial.print ("{");
for (i=0; i<4; i++){
Serial.print (PreviousInPin );
- if (i<3){*
- Serial.print (",");*
- }*
- }*
- Serial.print ("}");*
- Serial.println (" ");*
}
void loop() {
- // put your main code here, to run repeatedly:*
int sensorValue1= digitalRead (IN1);
int sensorValue2= digitalRead (IN2);
int sensorValue3= digitalRead (IN3);
int sensorValue4= digitalRead (IN4);
int PreviousInPin[4] = {sensorValue1,sensorValue2 ,sensorValue3 ,sensorValue4};
/*PreviousInPin[0]= sensorValue1;
PreviousInPin[1]=sensorValue2;
PreviousInPin[2]=sensorValue3;
PreviousInPin[3]=sensorValue4;*/
int CurrentInPin[4] = {new_sensorValue1,new_sensorValue2 ,new_sensorValue3 ,new_sensorValue4};
/CurrentInPin[0]=new_sensorValue1;
CurrentInPin[1]=new_sensorValue2;
CurrentInPin[2]=new_sensorValue3;
CurrentInPin[3]=new_sensorValue4;/
if (PreviousInPin[4] != CurrentInPin[4] ){
Serial.print ("CurrentInPin [4]=");
Serial.print ("{");
for (j=0; j<4; j++){
Serial.print (CurrentInPin );
if (j<3){
Serial.print (",");
}
}
Serial.print ("}");
Serial.println (" ");
CurrentInPin [4] = PreviousInPin [4];
}
delay (10);
}