Toggle Switch Unpredictable In One Program

[Posts in the debugging category need to have the following pieces of information included in order to help other teachers or our moderator team best help you. Feel free to delete everything in brackets before posting your request for debugging help.]

Link to the project or level: [This is CSD U6a Lessson 15 Level 6b]
What I expect to happen: [I expect the color LEDs to turn yellow when the toggle switch is closed and to turn off when the switch is open. I expect the external LEDs connected to pins A0 & A6 to turn off when the switch is open and on with the switch is closed. I also expect a message in the console reporting each time the toggle switch opens and closes.]
What actually happens: [The behavior is unpredictable. Sometimes the toggle switch doesn’t seem to do anything. Sometimes when I open it I see 2 console messages (open for close and one for open) and the color LEDs are all yellow. I never see the external LEDs turn on .]
What I’ve tried:

  • different CP boards
  • removing the wires completely. I figured I would at least see the colorLEDs go on and off.
  • going back to * CSD unit 6a lesson 6 which uses the toggle switch and the toggle switch worked just as expected.
  • I tried swapping “open” and “close” in the onBoardEvents to see if that matters.

Any thoughts?

John

I have more info…

I went to the next level (6c) and got that to work with the same external LEDs that I have connected to the board for the level 6b.

The wires were not making good contact, so I fixed that and everything worked. I tested it with both A6 and A0. The LED goes on and off based on the light sensor value.

Then I went back to level 6b (the toggle switch) and it seemed to work once. It is difficult to use the toggle switch without disturbing the wires and I think they are sensitive.

However, I am still not sure why this app does not make the color LEDs go on and off with the toggle switch when the wires are not connected at all.

John

Hi @jwilson25

When I run your code, I would get different results but I couldn’t tell you exactly all the reasons. Sometimes the lights would flash when I toggled the switch and sometimes the lights would turn off but not back on. One thing that is obvious from the console text is that open and close changes are not consistently detected. I even tried two different boards. I did change Board Event to left button down and left button up and it did exactly as expected changing the lights to yellow and then to off. Sorry I am not more help. You can report the problem to support.

~Michelle