Shop OBEX P1 Docs P2 Docs Learn Events
New to the Basic stamp 2 — Parallax Forums

New to the Basic stamp 2

Maintenance manMaintenance man Posts: 17
edited 2011-11-25 22:26 in General Discussion
Hi to all,
I am new to the Basic stamp 2 in which we are using it in our Mechatronics class to learn some basic microcontroller programming. We are using the book” What’s a Microcontroller ? “student workbook version 1.9 Stamps in Class. I enjoy learning about electronics which includes microcontrollers.We have been working with blinking LEDs and servo motors. At the end of each chapter there are the challenges in which I find very fun. I was wondering if there was a place in this forum that shows some examples of these challenges so I can compare my programs to some other examples that others have done. In the book I am using ,the servo motor controlling starts in chapter 3 in which I would like to see some examples of servo control for the end of chapter challenges for chapters 3, 4, 5 and 6. Thank you all for your help in advance.
Sincerely:
Maintenance Man

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2011-11-25 18:00
    Welcome Maintenance man to the Parallax Forum

    Here is what I would do is put what you have as far as the code you have and I am sure there is some on this forum would glad to help you with it
  • FranklinFranklin Posts: 4,747
    edited 2011-11-25 18:08
    Also, so you will know in the future.Posting the same post in more than one forum is against forum policy. If you get to your other post before it has been replied to you can delete it.
  • Maintenance manMaintenance man Posts: 17
    edited 2011-11-25 18:20
    Sorry, I will not do it again. Thank you for your help.
  • Maintenance manMaintenance man Posts: 17
    edited 2011-11-25 19:00
    From What's a Microcontroller; Student Workbook Version 1.9; Chapter 3 Challenge 1.
    Write a program ( complete with remarks) that will turn on the LED (on P5) every time the servo reaches one extreme of its travel, then turn the LED off when it reaches the other extreme.

    This is the program that I have written, which worked ok. Any input would be greatly appreciated; negative or positive input appreciated to help make me a better programmer of the basic stamp 2. I tried to space the remarks from the program when I saved it, but it will not let me space the remarks.from the prgram in this post. Sorry.

    ' { $TAMP BS2}

    x VAR Word 'A variable called X one word long
    OUTPUT 12 'Make P12 a output
    OUTPUT 5 'Make P5 a output
    here: 'A label
    FOR x = 1 TO 100 'Beginning of a for...next loop
    PULSOUT 12, 500 'Determins the duration of the pulse on output 12
    PAUSE 10 'Pause for 10 ms
    NEXT 'If x has reached 100 at this stage, the program will continue
    LOW 5 'Turn on LED at pin 5
    PAUSE 500 'Pause for 500 ms
    FOR x = 1 TO 100 'beginning of a for... next loop
    PULSOUT 12, 1000 'Determins the duration of the pulse on output 12
    PAUSE 10 ' Pause for 10 ms
    NEXT 'If x has reached 100 at this stage , the program will continue
    HIGH 5 'Turn off the LED at pin 5
    PAUSE 500 'Pause for 500 ms
    GOTO here 'Go back to the here label and do it all again
  • FranklinFranklin Posts: 4,747
    edited 2011-11-25 22:26
    If you go to the advanced editing features you can wrap the code in CODE tags that will keep the spacing. You can also go back and edit your previous post to format the text.
Sign In or Register to comment.