wtf...double post and I don't know why...READ BELOW![]()
wtf...double post and I don't know why...READ BELOW![]()
Last edited by .n0rig.; - 5th February 2009 at 00:21.
This is what I did to test it with your code and it worked perfectly
BRILLIANT! I LOVE YOU! (just...I apreciate youCode:Start: PORTc.1 = 1 'turn communication pin high TRAIN=$55 MOVEMENT VAR BYTE[2] 'ARRAY VARIABLE SERIN2 PORTC.1,396,[WAIT("9"),STR MOVEMENT\2] direction = MOVEMENT[0] turns = MOVEMENT[1] if turns = 1 then high porta.1 if turns = 2 then high porta.5 else goto start endif endif ;goto checkdirection goto start)
Now to learn how to wire those buttons up so that they work when I press them down...I really don't know anything about that. Lets say I have porta.1 connected to a button that is also connected to ground pin (which is connect to ground...). In my code, will I be looking for a "0" or "1". *just thought of this: will I have to use the poke command to get the status of the pin (either low or high)*
Regards,
n0rig
Last edited by .n0rig.; - 5th February 2009 at 00:13.
Have one side of the button connected to 5 volts, the other to the PIC pin. Have a 10 k resistor connected to the same PIC pin and ground (zero).
When the button is pushed ( assuming it is NO ) the PIN pin will be forced HIGH, that is 1.
Being this sounds like a school project, can you tell me why the below worked?Code:IF PORTA.1 = 1 THEN LABEL![]()
Code:SERIN2 PORTC.1,396,[WAIT("9"),STR MOVEMENT\2]
Dave
Always wear safety glasses while programming.
I am assuming that it "waited" to receive a digit of 9, then the array of 2 movement split the next 2 incoming bytes into the array.
That part worked if afterward I did a check on what digit was sent (in this case, a 1), and then if it was a 1, to turn the pin porta.1 high. This worked and turned an LED i had put there on. Buttttt, when I did the same thing with the following if then statements...it did not work:
I am not sure why it would not work...Code:;lets get moving! checkdirection: ;forward and backwards if direction = 0 then goto checkturns if direction = 1 THEN goto forward if direction = 2 then goto backward endif endif endif checkturns: ;forward and backwards if turns = 0 then goto start start_turn: if turns = 1 THEN goto turnleft if turns = 2 then goto turnright endif endif endif goto start ;left and right turns forward: if turns = 0 then goto forwardgo if turns = 1 THEN goto forwardleft if turns = 2 then goto forwardright endif endif endif forwardgo: high forwardl high forwardr pause 500 low forwardl low forwardr goto start
Bookmarks