Computer Science Canada How to get Lights to stop flickering |
Author: | jSong [ Fri May 24, 2013 9:30 am ] | ||
Post subject: | How to get Lights to stop flickering | ||
What is it you are trying to achieve? I am trying to have my so-called loft lights turn on when pressing assigned buttons. This is for my summative assignment. This is also my first time programming EVER. So sorry if it is messy and I made a lot of stupid mistakes ! What is the problem you are having? Well, my issue here is that I am trying to have both lights turn on when I press the assigned key 'd'. The issue is that it keeps on flickering as to the rest of my commands (A and D) that are working fine. Basically I am trying to ask how do I prevent this and I would actually like to know why this is happening ![]() Describe what you have tried to solve this problem I have tried entering a delay but it stays on for to long and so it doesn't really go along with what I am trying to do. :/ Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using 4.1.1 |
Author: | MihaiG [ Fri May 31, 2013 5:26 pm ] |
Post subject: | Re: How to get Lights to stop flickering |
You have a good idea of what's going on! But let me asking you a question when you turn on a light switch, does it have more than two modes in general? It shouldnt! Majority light switches as seemed to be part of the scope here is using on or off.. Now what data type might we use to signify two distinct states? Now we have an idea that we have 2 lighting areas, bedroom and living room, how many of these data types are we going to need? So now that's setup. So we have to ask ourselves a question, when we turn on a switch and hold it, does the light stay on? What happens when we let go (in your program lights go off). So you need to find a way to check..ie If light a is off and i press a, then turn it on. If light a is off and i press a. turn it off! What happens if i hold a, chances are it might flicker! does this happen i real life? No! So we need to address that, we do that my monitoring if there's been a keypress activated! This should help you develop your logic. Try and write down your ideas and thought process in words! It makes it easier. To reduce flickering when animating in turing. Look into View.Update and how that works! The documentation is fairly easy to understand! |