Hello fellas,
I am programming an atmega32 using Arduino as ISP.
The outputs go all HIGH for a few ms which causes system misbehavior for that short moment.
The portion of the code is
The attached gif in slow motion makes it clear.
I am programming an atmega32 using Arduino as ISP.
The outputs go all HIGH for a few ms which causes system misbehavior for that short moment.
The portion of the code is
Code:
while (goup) { //// lift is going up
Serial.print("current_floor is");
Serial.println(current_floor, DEC);
Serial.print("Destination floor is");
Serial.println(destination_floor, DEC);
Serial.print("E-floor is");
Serial.println(e_floor, DEC);
//delay(500);
difference = destination_floor - current_floor;
e_difference = e_destination - e_floor;
lift_display.showNumberDec(current_floor);
state_change_DSS(DSS);
state_change_USS(USS);
Serial.print("DSS= ");
Serial.print(buttonPushCounter_DSS, DEC);
Serial.print(" USS= ");
Serial.println(buttonPushCounter_USS, DEC);
if( digitalRead(incremented) == HIGH)
Serial.println(" incremented is high ");
else if ( digitalRead(incremented) == LOW)
Serial.println(" incremented is low ");
if((buttonPushCounter_DSS % 2 == 0 && buttonPushCounter_USS % 2 == 0 && e_difference > 1) ) {
if(!incremented){
e_floor++;
incremented = HIGH;}
lift_display.showNumberDec(e_floor);
}
else if((buttonPushCounter_DSS % 4 == 0 && buttonPushCounter_USS % 4 == 0 && difference > 1) ) {
if(!incremented){
current_floor=2;
incremented = HIGH;}
lift_display.showNumberDec(current_floor);
}
else if((buttonPushCounter_DSS % 2 == 0 && buttonPushCounter_USS % 2 == 0 && difference == 1) ) {
if(!incremented){
current_floor++;
incremented = HIGH;}
lift_display.showNumberDec(current_floor);
lift.setAll(UP_LOW);
}
else if((buttonPushCounter_DSS % 2 == 0 && buttonPushCounter_USS % 2 == 0 && difference == 0) || (buttonPushCounter_DSS % 3 == 0 && buttonPushCounter_USS % 2 == 0 && difference == 0) || (buttonPushCounter_DSS % 5 == 0 && buttonPushCounter_USS % 4 == 0 && difference == 0)){
incremented = LOW;
lift.setAll(UP_LOW);}
else if((buttonPushCounter_DSS % 3 == 0 && buttonPushCounter_USS % 3 == 0 && difference == 0) || (buttonPushCounter_DSS % 5 == 0 && buttonPushCounter_USS % 5 == 0 && difference == 0)) {
lift.setAll(off);
lift_display.showNumberDec(current_floor);
incremented = LOW;
goup = LOW;
}
else {
incremented = LOW;
lift.setAll(UP_HIGH);
}