Translate code..


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    48

    Default Translate code..

    Could someone pls translate this code to Basic?

    Code:
    ' {$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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    It is in basic

    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.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    I copied from another site so I dont konw :P

    Is 'INPUT' the same as 'HIGH'?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    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..

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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.
    Code:
             ' {$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.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts