Computer Science Canada Parallelput problem |
Author: | NEOS [ Sat Nov 08, 2008 8:02 am ] |
Post subject: | Parallelput problem |
loop mousewhere (xmouse, ymouse, button) locate (21, 20) put " To go to the MAIN SCREEN" put " click on box ." drawbox (550, 30, 600, 80, 10) if xmouse >= 75 and xmouse <= 105 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (89, 240, 15, 15, 4) a := 1 m := a + m parallelput (m) elsif xmouse >= 141 and xmouse <= 171 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (155, 240, 15, 15, 4) b := 2 m := m + b parallelput (m) elsif xmouse >= 207 and xmouse <= 242 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (221, 240, 15, 15, 4) c := 4 m := m + c parallelput (m) elsif xmouse >= 273 and xmouse <= 308 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (287, 240, 15, 15, 4) d := 8 m := m + d parallelput (m) elsif xmouse >= 339 and xmouse <= 374 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (353, 240, 15, 15, 4) e := 16 m := m + e parallelput (m) elsif xmouse >= 405 and xmouse <= 440 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (419, 240, 15, 15, 4) f := 32 m := m + f parallelput (m) elsif xmouse >= 471 and xmouse <= 506 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (485, 240, 15, 15, 4) g := 64 m := m + g parallelput (m) elsif xmouse >= 537 and xmouse <= 572 and ymouse >= 270 and ymouse <= 300 and button = 1 then drawfilloval (551, 240, 15, 15, 4) h := 128 m := m + h parallelput (m) elsif xmouse >= 550 and xmouse <= 600 and ymouse >= 30 and ymouse <= 80 and button = 1 then cls title end if end loop that's a part my project and whenever I plug it in to the breadboard the lights are supposed to flash according to the buttons pressed but for some reason whenever I click a button it'll mess up and turn a bunch of other buttons on to so I need to make it turn on the button I pressed and when I press another button they both stay on. |
Author: | Insectoid [ Sat Nov 08, 2008 9:10 am ] |
Post subject: | RE:Parallelput problem |
First, use code tags. Second, we need a circuit diagram to be able to help you. This is probably a problem with your wiring. |
Author: | Euphoracle [ Sat Nov 08, 2008 9:49 am ] |
Post subject: | RE:Parallelput problem |
You're not resetting m... after a while it will always be outputting >255 and your circuit will glow bright. At least, that's what it looks like the problem is. |
Author: | NEOS [ Sat Nov 08, 2008 3:08 pm ] |
Post subject: | Re: Parallelput problem |
ok here's how the output window looks like. |
Author: | NEOS [ Sat Nov 08, 2008 3:09 pm ] | ||
Post subject: | Re: Parallelput problem | ||
So how do I reset "m"
|
Author: | Insectoid [ Sat Nov 08, 2008 4:09 pm ] |
Post subject: | RE:Parallelput problem |
m := 0 The way I would do this is I would assign a boolean variable to every light to represent on/off (true/false). Then I would use a for loop to check if that light is supposed to be on and add it's value to a running total, then send it all through the parallel port. |
Author: | NEOS [ Sat Nov 08, 2008 4:51 pm ] | ||
Post subject: | Re: Parallelput problem | ||
how do you use a for loop to check? Is it like this?
|
Author: | Euphoracle [ Sun Nov 09, 2008 9:00 am ] | ||
Post subject: | RE:Parallelput problem | ||
No, you just do
|
Author: | Insectoid [ Sun Nov 09, 2008 10:59 am ] | ||
Post subject: | RE:Parallelput problem | ||
An array of boolean variables.
|
Author: | NEOS [ Sun Nov 09, 2008 12:59 pm ] | ||
Post subject: | Re: RE:Parallelput problem | ||
insectoid @ Sun Nov 09, 2008 10:59 am wrote: An array of boolean variables.
So I put that under each "elsif"? and an erroe comes up because of "true" the error states "Operands of comparison operators must be of the same type." What does that mean I tried changing it to "false" but the same thing happens |
Author: | Insectoid [ Sun Nov 09, 2008 1:08 pm ] |
Post subject: | RE:Parallelput problem |
You don't need any other 'ifs' at all. This does the whole thing. 'array1' must be an array of boolean. I suggest looking through the Turing Walkthrough. 'Operands of comparison...' means that you are trying to compare different types of variables. Something like 'if string = int' or 'if int = boolean' |
Author: | NEOS [ Sun Nov 09, 2008 1:10 pm ] |
Post subject: | Re: RE:Parallelput problem |
insectoid @ Sun Nov 09, 2008 1:08 pm wrote: You don't need any other 'ifs' at all. This does the whole thing. 'array1' must be an array of boolean. I suggest looking through the Turing Walkthrough.
'Operands of comparison...' means that you are trying to compare different types of variables. Something like 'if string = int' or 'if int = boolean' so I delete all of those "ifs" |
Author: | andrew. [ Sun Nov 09, 2008 1:43 pm ] |
Post subject: | RE:Parallelput problem |
Yes. Delete the other ifs. Insectoid's code keeps track of whatever is on and off and if it is true, it will automatically add the numbers. |