PDA

View Full Version : Translate code..



xobx
- 16th July 2007, 17:06
Could someone pls translate this code to Basic?



' {$STAMP BS2}
' {$PBASIC 2.5}


R PIN 15
X PIN 14
Y PIN 13
G PIN 12


INPUT R
INPUT X
INPUT Y
LOW G

DO

DO
PAUSE 50
LOOP UNTIL IN7=1

'First R
LOW R
PAUSE 136
INPUT R
PAUSE 30

'Second R
LOW R
PAUSE 38
INPUT R

'X
LOW X
PAUSE 50
INPUT X
PAUSE 210

'Double Y
LOW Y
PAUSE 50
INPUT Y
PAUSE 50
LOW Y
PAUSE 50
INPUT Y
PAUSE 200

LOOP

mackrackit
- 16th July 2007, 17:55
It is in basic:D

The big thing to change is RXYG. Use VAR to give them at PORT?.?

What PIC are you going to use? Do you need help with the config?

Get rid of INPUT statements.

And did it work on the stamp? Where is END?

What I see looks like it would be just as easy to start over though.

I know this is not much help now, but I do not have Stamp stuff with me.

Will check back later to see if you need more help.

xobx
- 16th July 2007, 18:04
I copied from another site so I dont konw :P

Is 'INPUT' the same as 'HIGH'?

mackrackit
- 16th July 2007, 18:12
INPUT makes the pin an input. That is what makes things look funny. INPUT used to many times, but is has been awhile since I used a stamp.

How about we do this. Tell what this thing is going to do and the PIC used and we start from scratch.

I am going to be off line for a few hours but I will get back with you if you want to do it that way.

xobx
- 16th July 2007, 18:24
Im going to do this

http://www.instructables.com/id/EBQXQEC6XNEY95VH90/

And the creator wont share his code, and I found that code in the comments..


D'oh! This was under the code..

~~
I used Input instead of high because leaving the buttons high would make it unable for you to use the buttons while not doubleshoting. I find this code to work almost everytime with my regular Xbox. If you have any other question's I'll try my best to answer them.
~~

But I cant see what 'G' does..

mackrackit
- 17th July 2007, 10:40
After reading the link you gave I am afraid that I can not be of much help. I do not know anything about the xbox.

Here is what little I could figure out.
1 – The xbox button/switches must be pulled LOW foe something to happen.
2 – The information given about the project is incomplete, might make a good soldering tutorial.
3 – The code you have is not very good, even the author said it works MOST of the time.

I added some comments to the code you have. Hopefully it will explain some.


' {$STAMP BS2}
' {$PBASIC 2.5}


R PIN 15 ' R X Y G switches OR buttons on xbox?
X PIN 14
Y PIN 13
G PIN 12


INPUT R 'in PBP same as TRIS?.? = 1
INPUT X
INPUT Y
LOW G 'is not used in program

DO

DO
PAUSE 50
LOOP UNTIL IN7=1 'New switch ??? See comment below

'First R
LOW R 'makes pin LOW (0)
PAUSE 136
INPUT R 'in PBP same as TRIS?.? = 1
PAUSE 30

'Second R
LOW R
PAUSE 38
INPUT R

'X
LOW X
PAUSE 50
INPUT X
PAUSE 210

'Double Y
LOW Y
PAUSE 50
INPUT Y
PAUSE 50
LOW Y
PAUSE 50
INPUT Y
PAUSE 200

LOOP


The DO-LOOP in stamp language is similar to WHILE..WEND in PBP but backwards.
IF-THEN-ELSE could also be made to work. The idea is to keep the program in a loop until a condition is met.

Suggestions to you.
1 – If you already have PBP, forget about trying to convert BS2 stuff from someone else.
2 – Study PBP and become comfortable with a hand full of LEDs and switches and a PIC or two.
3 – If you are planning on a project like this one, study the device. Web sites like the one you have been looking at are a waste of time.

The most important thing is not to give up. I have been playing with PICs for seven years now and I am still a beginner. Built a lot of “cool” things, but still a beginner.

xobx
- 17th July 2007, 12:13
The only thing im looking on that tutorial is the soldering points for the buttons..

And the code work most of the time because the weapon you use must be full and you must have a secondary weapon..

And I think I understand the code now :)

Pic_User
- 17th July 2007, 13:13
Hi xobx,

There are a lot of general soldering technique, demos on the web.

klee27x shows a bit of detail for the connections.
Knowing nothing about the Xbox, I would guess the PIC I/Os go across each push button switch connection.
Then the PIC can “push the button” for you.
Problem is the PIC I/Os have to be “high impendence” when not low, so the normal push buttons can pull the circuit low.
klee27x has done this by turning the I/Os into inputs.
<IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1861&stc=1&d=1184673824">
One glaring omission from the tutorial, No “By-Pass” capacitor(s).
Right AT the power supply pins of the PIC (Vdd to Vss).
This fact should jump out at us because the long “wire-wrap” wire should LOOK like an inductance to us. PCB or PWB also have inductance but no so much “in your face”, obvious.

-Adam-