Shop OBEX P1 Docs P2 Docs Learn Events
Elevator Controls — Parallax Forums

Elevator Controls

M. WilsonM. Wilson Posts: 4
edited 2008-08-18 19:53 in BASIC Stamp
Hi everybody:
······ I am having problems putting together the servo controls and the push button controls. Separately they work fine.· However when I put them together the servo will not work.· I built the servo from figure 4-21, page 130 of the "What's a microcontroller?" book.· I think the out put from the push button controls, P-15 (pg. 1) must be linked to the servo input before the servo will take commands.· When P-15 (pg.1) goes high it should·cause the servo to rotate cw·180 degrees, pause seven seconds, then rotate 180 degrees.

I would appreciate any help you can give me.

M. Wilson
1072 x 1743 - 99K
1275 x 1750 - 70K
1275 x 1750 - 92K
1254 x 1616 - 249K

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-08-18 01:29
    OK, point 1, when you attach code please use the Attachment Manager and attach the real code you are using. For me, looking at bad pictures of code does me no good. Sorry

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SRLMSRLM Posts: 5,045
    edited 2008-08-18 06:11
    Did you take a picture of a printout? You could have saved the ink by just taking a screen shot. Also, you can just link or refer to the page in the book: anybody can access it so no need to worry about getting out the right page. Anyway, the best way to attach code is to use the source file.

    Second: what exactly is your project?
  • M. WilsonM. Wilson Posts: 4
    edited 2008-08-18 18:39
    sorry I attached it wrong...

    I am working on model·Elevator controls

    Here's a better attachment. The servo controls I used is located on page 130 of "What's a Microcontroller" Book
  • SRLMSRLM Posts: 5,045
    edited 2008-08-18 19:53
    First off, you should replace all you pin numbers with names. This is easy: just declare it at the begining. It will help everyone understand your code.

    button PIN 15
    LED PIN 16
    'etc



    Next up is lines 69 to 71 (the loop.) You have it set so that it loops 7 thousand times. Bad idea. You can just insert a PAUSE 7000 to make it idle for seven seconds. Same idea at 83 to 85.

    Now that I've covered that, might I add that the code will *never* reach that section since it is preceeded by a DO-LOOP with no possibility of escape. Your best bet would be to place the servo stuff in a method, that you then call with GOSUB. You then call the method after testing for the button. You also don't need the LOW 14 at line 45 since that is your servo line. Final note: use comments! I have no idea what all that stuff in the DO-LOOP is supposed to do, and your code is no help. It looks like you test a bunch of things, but why? What are the preconditions and post condidtions? Comments are an essential part of all programming.
Sign In or Register to comment.