Menu

(no subject)

2017-08-20
2017-08-20
  • Evandro Rech

    Evandro Rech - 2017-08-20

    Hi! I'm using SimulIDE 0.0.4-Win32-SR3 to teach Arduino in a class, and I think we found a some kind of bug this week.

    We are working in a exercise with 3 buttons and 3 LEDs, and the program needs to control each LED independent of the others, when pushing button1, LED1 changes his state and so on. The program is this:

    const int led1=8, led2=9, led3=10, button1=5, button2=6, button3=7;
    boolean ledState1=LOW, ledState2=LOW, ledState3=LOW;
    
    void setup(){
      pinMode(led1, OUTPUT);
      pinMode(button1, INPUT_PULLUP);
      pinMode(led2, OUTPUT);
      pinMode(button2, INPUT_PULLUP);
      pinMode(led3, OUTPUT);
      pinMode(button3, INPUT_PULLUP);
    }
    
    void loop(){
      if(digitalRead(button1)==LOW){
        ledState1 = !ledState1;
        digitalWrite(led1,ledState1);
    
        while(digitalRead(button1)==LOW);
      }
    
      if(digitalRead(button2)==LOW){
        ledState2 = !ledState2;
        digitalWrite(led2,ledState2);
    
        while(digitalRead(button2)==LOW);
      }
    
      if(digitalRead(button3)==LOW){
        ledState3 = !ledState3;
        digitalWrite(led3,ledState3);
    
        while(digitalRead(button3)==LOW);
      }
    }
    

    The circuit was:
    Bug-0

    That circuit doesn't work corretly, and I tried with and without the LED "trick" (internally connecting with GND). After a first button press, the correspondent LED lights, but all other buttons stop to work, and subsequent button presses didn't work.

    If I change the circuit (and program) to only use the first row of pins (2~7), the circuit works.
    Bug-1

    Also, I tested that second aproach without connecting the LEDs to GND internally, and it only works if I use two different GND connections, one for the LEDs and one for the buttons, with only one GND, the problem repeats.

    I noted too, when reopening some files, a line appears on the GND connection:
    Bug-3

    I hope that all can help you in the SimulIDE development!

    Thanks and congratulations!

    Evandro Rech

     

    Last edit: Evandro Rech 2017-08-20
  • Santiago

    Santiago - 2017-08-21

    Hi Evandro.

    Thank you very much for reporting this problem.

    I tested it and the problems is abut using inputs with internal pullups, if you try adding external resistor everything should work properly.

    Let me see what can i do, not sure it has a fast solution as it is related with how simavr works.
    I will try to solve the issue for next release that will be available in some days.
    In his release you will also be able to compile, upload and basic debugging within simulide.

    The weird connections that appears sometimes is solved and will be included in next release.

    It is very important that users report problems because we can not test every possible case.

    Regards.

     
  • Santiago

    Santiago - 2017-08-21

    Update:

    Issue is solved and will be fixed in next release.

     
  • Evandro Rech

    Evandro Rech - 2017-08-21

    Thanks Santiago! I'll continue to use SimulIDE in my class and if we have some problem, I will share with you!