hey ..
i' m just tring to do something very easy but even that won't work .. can you please help me out ..
[noparse][[/noparse]code]
pub main
if ina
dira[noparse][[/noparse]8] ~~
repeat
!outa[noparse][[/noparse]8]
waitcnt(3_000_000 + cnt )
[noparse][[/noparse]/]
so ina 1 is a switch and outa 8 is a led .. what i'm tring to do is just clcik on the swith and the led must start pinking
but it won't do that .. what do i do wrong ?
please help .
wat is je moedertaal ?
bij mij nederlands .. en het is gelukt met het vorige .. tog bedankt ( srry )
maar hij wilt het niet doen .. ben nu mijn hardware aan het aanpassen . zoals het in de editor staat [noparse];)[/noparse]
grtz
Well,
(1) Could you both please post your code as code! This should not be a matter of the mother language...
(2) I think some problems are caused by wrind indention
(3) And if you don't include the IF inside the REPEAT-loop, this will stay a tricky program
I speak Dutch... but only in English[noparse]:)[/noparse]
The indentation gets messed up in the posts. Try taking a snapshot of your code and attaching it.
pub memory
w := 1
z := 0
repeat 17
repeat w
X := startpin + ||i?//8 ' set X to a random number from 0 to 8 , starpin for the output. if the random number =0 it will start at a defined pinnumber
dira[noparse][[/noparse]X] ~~
!outa[noparse][[/noparse]X] ' put the led on
waitcnt(delay + cnt )
' waiting time to hold the led lighted
if outa[noparse][[/noparse]x] ' put pin X on 1 ( light op a led)
outputreg [noparse][[/noparse]z] === x ' to save what outpin has gone to 1
z === z + 1 ' z must add by 1 so the next won't overwrite the array
outa[noparse][[/noparse]x]===0
repeat
if ina
x := 1
repeat
until w===x
if ina[noparse][[/noparse]0] === 1 ' next lines are to see what switsh is pressed
inputreg [noparse][[/noparse]j] === 8
j := j + 1
x:=x+1
elseif ina == 1
inputreg[noparse][[/noparse]j] === 9
j := j + 1
x:=x+1
elseif ina === 1
inputreg[noparse][[/noparse]j] === 10
j := j + 1
x:=x+1
elseif ina === 1
inputreg[noparse][[/noparse]j] === 11
j := j + 1
x:=x+1
elseif ina === 1
inputreg[noparse][[/noparse]j] === 12
j := j + 1
x:=x+1
elseif ina === 1
inputreg[noparse][[/noparse]j] === 13
j := j + 1
x:=x+1
elseif ina[noparse][[/noparse]6] === 1
inputreg[noparse][[/noparse]j] === 14
j := j + 1
x:=x+1
elseif ina[noparse][[/noparse]7] === 1
inputreg[noparse][[/noparse]j] ===15
j := j + 1
x:=x+1
quit
v === 0
repeat w
if outputreg[noparse][[/noparse]v] == inputreg[noparse][[/noparse]v] ' compare the values in the 2 arrays
v := v + 1
w:=w+1
i also have an other question .. can i have a debug form to see what the prop.chip is doing from code?
@elecnoob: Why do I post at all? My impression is, you are a highly intelligent person;
I doubt someone with an IQ lower that 140 can think of all the nonsense you are doing.
I in fact do enjoy it! MENSA? An alien?
I believe = = = is the usual case of the overloaded assignment operator like += or &=.
X === Y is identical to X := X == Y which sets X true (-1) if X == Y and false (0) otherwise, just like rjo_ found.
so the === isn't equal ? ...
because if i said == the program says to me that the varriable needs an operator ..
so i just used the === because my small datasheet says that == is the same as ===
One by one
I asked you about 24 hours ago to make the changes according to my suggestions,
and then post your code again, PLEASE.
The reason is, that after you do this, the about 4 grave logical errors in your program,
will be more obviuous to others - when you get rid of these idiotic ===
Thank you
ok i will post my code again .. but i made allot of changes ..
pub memory
dira[noparse][[/noparse]0] := 0
dira := 0
dira := 0
dira := 0
dira := 0
dira := 0
dira[noparse][[/noparse]6] := 0
dira[noparse][[/noparse]7] := 0
dira[noparse][[/noparse]8] := 1
dira[noparse][[/noparse]9] := 1
dira[noparse][[/noparse]10] := 1
dira[noparse][[/noparse]11] := 1
dira[noparse][[/noparse]12] := 1
dira[noparse][[/noparse]13] := 1
dira[noparse][[/noparse]14] := 1
dira[noparse][[/noparse]15] := 1
w := 1
repeat 17
x := 0
z := 0
j := 0
repeat 17
outputreg [noparse][[/noparse]x] == 0
inputreg [noparse][[/noparse]x] == 0
x := x + 1
repeat w
X := startpin + ||i?//8 ' set X to a random number from 0 to 8 , starpin for the output. if the random number =0 it will start at a defined pinnumber
dira[noparse][[/noparse]X] ~~
!outa[noparse][[/noparse]X] ' put the led on
waitcnt(delay + cnt )
' waiting time to hold the led lighted
outputreg [noparse][[/noparse]z] == x
'if outa[noparse][[/noparse]x] ' put pin X on 1 ( light op a led)
' outputreg [noparse][[/noparse]z] == x ' to save what outpin has gone to 1
z := z + 1 ' z must add by 1 so the next won't overwrite the array
outa[noparse][[/noparse]x] == 0
waitcnt(delay2 + cnt )
repeat w ' to see what switch is pressed
repeat
if ina [noparse][[/noparse]0..7]
outa[noparse][[/noparse]8] := ina[noparse][[/noparse] 0 ]
outa[noparse][[/noparse]9] := ina[noparse][[/noparse] 1 ]
outa[noparse][[/noparse]10] := ina[noparse][[/noparse] 2 ]
outa[noparse][[/noparse]11] := ina[noparse][[/noparse] 3 ]
outa[noparse][[/noparse]12] := ina[noparse][[/noparse] 4 ]
outa[noparse][[/noparse]13] := ina[noparse][[/noparse] 5 ]
outa[noparse][[/noparse]14] := ina[noparse][[/noparse] 6 ]
outa[noparse][[/noparse]15] := ina[noparse][[/noparse] 7 ]
'if ina[noparse][[/noparse]0]
' inputreg [noparse][[/noparse]j] := 8
' j := j + 1
'elseif ina
' inputreg[noparse][[/noparse]j]:= 9
' j := j + 1
'elseif ina
' inputreg[noparse][[/noparse]j] := 10
' j := j + 1
'elseif ina
' inputreg[noparse][[/noparse]j] := 11
' j := j + 1
'elseif ina
' inputreg[noparse][[/noparse]j] := 12
' j := j + 1
'elseif ina
' inputreg[noparse][[/noparse]j] := 13
' j := j + 1
'elseif ina[noparse][[/noparse]6]
' inputreg[noparse][[/noparse]j] := 14
' j := j + 1
'elseif ina[noparse][[/noparse]7]
' inputreg[noparse][[/noparse]j] :=15
' j := j + 1
waitcnt(delay2 + cnt )
outa[noparse][[/noparse]8] := 0
outa[noparse][[/noparse]9] := 0
outa[noparse][[/noparse]10] := 0
outa[noparse][[/noparse]11] := 0
outa[noparse][[/noparse]12] := 0
outa[noparse][[/noparse]13] := 0
outa[noparse][[/noparse]14] := 0
outa[noparse][[/noparse]15] := 0
quit
' v := 0
' repeat w
' if outputreg[noparse][[/noparse]v] == inputreg[noparse][[/noparse]v] ' compare the values in the 2 arrays
' v := v + 1 ' next array
' w:=w+1
all the ' are because i'm just testing the program step by step ..
right now ..
the leds turn on and of in a random sequence and wait till as mutch as buttons are pushed as there wereled lighted on
== to place something in an arry
and := for all the others
( but like i said .. the lines behind the ' i need to change before i can use it .. they are from a edition before this 1 .. but that didn't work so now i'm trying
to rewrite it .. in steps ..
Comments
i' m just tring to do something very easy but even that won't work .. can you please help me out ..
[noparse][[/noparse]code]
pub main
if ina
dira[noparse][[/noparse]8] ~~
repeat
!outa[noparse][[/noparse]8]
waitcnt(3_000_000 + cnt )
[noparse][[/noparse]/]
so ina 1 is a switch and outa 8 is a led .. what i'm tring to do is just clcik on the swith and the led must start pinking
but it won't do that .. what do i do wrong ?
please help .
repeat
outa[noparse][[/noparse]8]:=0
while ina[noparse][[/noparse]pinnummer]==1
repeat
!outa[noparse][[/noparse]8]
waitcnt(3_000_000 +cnt)
he gives a error on the while.. and i don't get it he ecpects an instruction or variable .. insted of the while
Mischien werkt deze bij je:
PUB Toggle
dira[noparse][[/noparse]outpin]~~
dira[noparse][[/noparse]inpin] := 1
repeat
outa[noparse][[/noparse]outpin]:=0
repeat while ina[noparse][[/noparse]inpin] == 1
!outa[noparse][[/noparse]outpin]
waitcnt(3_000_000 +cnt)
groetjes
Franz
bij mij nederlands .. en het is gelukt met het vorige .. tog bedankt ( srry )
maar hij wilt het niet doen .. ben nu mijn hardware aan het aanpassen . zoals het in de editor staat [noparse];)[/noparse]
grtz
groetjes
Franz
can it be that the switch on the inputport doesn't work that good because it's not the same construction
(1) Could you both please post your code as code! This should not be a matter of the mother language...
(2) I think some problems are caused by wrind indention
(3) And if you don't include the IF inside the REPEAT-loop, this will stay a tricky program
I speak Dutch... but only in English[noparse]:)[/noparse]
The indentation gets messed up in the posts. Try taking a snapshot of your code and attaching it.
Rich
i also have an other question .. can i have a debug form to see what the prop.chip is doing from code?
grtz
Well it has a meaning (though I doubt a useful one) but please forget this if you ever can!
To assign values, use ":="
The check for equaity, use "=="
Please change your program and post it again... PLEASE!
I doubt someone with an IQ lower that 140 can think of all the nonsense you are doing.
I in fact do enjoy it! MENSA? An alien?
=== is legal. Page 438.
X===Y
sets X to true (-1) if x=y, it sets X to (0) if not.
So, its essentially a shorted version of X == Y ? -1 : 0 (in C)? If so, COOL!
X === Y is identical to X := X == Y which sets X true (-1) if X == Y and false (0) otherwise, just like rjo_ found.
because if i said == the program says to me that the varriable needs an operator ..
so i just used the === because my small datasheet says that == is the same as ===
For the "inputreg[noparse][[/noparse] j ] := y" and similar places, you need the assignment operator ":=".
=== is a most systematic and obvious construction! (as =>= and =<= e.g.)
but here he gaives the error ...
I asked you about 24 hours ago to make the changes according to my suggestions,
and then post your code again, PLEASE.
The reason is, that after you do this, the about 4 grave logical errors in your program,
will be more obviuous to others - when you get rid of these idiotic ===
Thank you
all the ' are because i'm just testing the program step by step ..
right now ..
the leds turn on and of in a random sequence and wait till as mutch as buttons are pushed as there wereled lighted on
and := for all the others
( but like i said .. the lines behind the ' i need to change before i can use it .. they are from a edition before this 1 .. but that didn't work so now i'm trying
to rewrite it .. in steps ..
you can write:
This will improve readeability!
Post Edited (deSilva) : 8/24/2007 3:31:55 PM GMT
can i also do this with the dira?
"==" is a check for equality, to be used within IF, WHILE e.t.c