|
|
Cliffg37 Inner circle Long Beach, CA 2491 Posts |
I am teaching a robotics class for the first time and need to get familiar with (learn) the programming language P-Basic. Anyone know of a good book of internet scource for this? Thanks in advance.
Magic is like Science,
Both are fun if you do it right! |
gdw Inner circle 4884 Posts |
Shouldn't you know that before you become the teacher?
"You may say I'm a dreamer, but I'm not the only one."
I won't forget you Robert. |
Jonathan Townsend Eternal Order Ossining, NY 27297 Posts |
Probably quicker to search the term: PBASIC
http://a.parsons.edu/~traviss/cc/lab/pro......Prog.pdf for example
...to all the coins I've dropped here
|
randirain Inner circle Fort Worth, TX 1650 Posts |
I know Pbasic.
I use the parallax stamps in my props all the time. I learned from the Parallax book. Basic is basic, just the syntax is different. Randi |
randirain Inner circle Fort Worth, TX 1650 Posts |
This book will give you all the syntax and examples of programming in pbasic.
It's just not a step by step, "hello world" teaching book. http://www.parallax.com/Store/Books/BASI......ult.aspx There are a bunch of downloads here as well... http://www.parallax.com/tabid/440/Default.aspx Randi |
critter Inner circle Spokane, WA 2653 Posts |
Quote:
On 2012-01-14 19:42, gdw wrote: Sounds like that's what he's trying to accomplish.
"The fool is one who doesn't know what you have just found out."
~Will Rogers |
Devious Inner circle 2120 Posts |
Miss Rain,
You never cease to amaze girl! |
Cliffg37 Inner circle Long Beach, CA 2491 Posts |
Thanks Randi,
That was just what the Doctor ordered. I took over the class that was using a simple built in lego mindstorm system, and that was easy enough to use. Thier programming is all pictures and stuff, but I felt the need to take the group to the next level. This is what I do as a teacher, and I think most good tecahers would agree. Take the kids fromwhere ever they are and get then to the next level. I could have stayed with the easy stuff and been fine, but that is not good enough for me. If I need to learn more to teach more...then so be it.
Magic is like Science,
Both are fun if you do it right! |
gdw Inner circle 4884 Posts |
Quote:
On 2012-01-14 22:40, critter wrote: I meant that, perhaps one should thoroughly know the subject before they are even committed to teach it.
"You may say I'm a dreamer, but I'm not the only one."
I won't forget you Robert. |
randirain Inner circle Fort Worth, TX 1650 Posts |
Quote:
On 2012-01-15 10:25, gdw wrote: He never said he didn't know the BASIC language. If you've learned any type of basic language, you have learned them all. It's just the syntax is going to be a little different. One might be... Code:
<br>if a=1 then <br> b=2 <br> c=3 <br>endif <br> <br>Another might be... <br> <br>if a=1 <br> b=2 <br> c=3 <br>end if <br> <br>then again, another might be... <br> <br>if (a=1) then <br> b=2 <br> c=3 <br>end if <br> If you know any basic, all three make sense to you. When learning pbasic, note that the BS1 came out way before the BS2's. Programming a BS1 is very different than the BS2's. BS1 is much less detailed. You can't even do any of the examples above. To do a BS1, it would be... Code:
<br>main_tag: <br> if a=1 then var_tag <br> <br>var_tag: <br> b=2 <br> c=3 <br> Any questions.. just ask. Since you are doing robotics, you will use servos at some point. Those work with the 'pulsout' code. Here is some old sample code for my animatronic frog... Code:
<br>' {$STAMP BS2} <br>' {$PBASIC 2.5} <br> <br>OUTPUT 15 <br>OUTPUT 14 <br>OUTPUT 13 <br>OUTPUT 12 <br>OUTPUT 11 <br> <br>INPUT 0 <br>INPUT 1 <br>INPUT 2 <br>INPUT 3 <br>INPUT 4 <br>INPUT 5 <br>INPUT 6 <br>INPUT 7 <br>INPUT 8 <br>INPUT 9 <br>INPUT 10 <br> <br>eyes VAR Word <br>head VAR Word <br>mouth VAR Word <br>neck VAR Word <br> <br>neckBool VAR Bit <br> <br>eye=700 'set to center <br>mouth=1150 'set to close <br>head=690 'set to center <br>neck=750 'set to up <br> <br>prog_loop: <br> DO <br> IF (IN0=1 AND IN1=0) THEN eye=500 <br> IF (IN0=0 AND IN1=1) THEN eye=700 <br> IF (IN0=1 AND IN1=1) THEN eye=900 <br> <br> IF (IN2=1 AND IN3=0) THEN head=600 <br> IF (IN2=0 AND IN3=1) THEN head=690 <br> IF (IN2=1 AND IN3=1) THEN head=780 <br> <br> IF (IN4=1 AND IN5=0) THEN mouth=900 <br> IF (IN4=0 AND IN5=1) THEN mouth=1500 <br> IF (IN4=1 AND IN5=1) THEN mouth=1150 <br> <br> IF (IN6=1) THEN <br> IF (neckBool=0) THEN <br> IF (neck=320) THEN neck=750 ELSE neck=320 <br> neckBool=1 <br> ENDIF <br> ELSE <br> neckBool=0 <br> ENDIF <br> <br> IF (IN10=1) THEN <br> GOSUB player_pause <br> PAUSE 1000 <br> GOSUB player_pause <br> GOTO idle_loop <br> ENDIF <br> <br> PULSOUT 15, eyes <br> PULSOUT 14, head <br> PULSOUT 13, mouth <br> PULSOUT 12, neck <br> LOOP <br> <br>idle_loop: <br> DO <br> <br> LOOP <br> <br>player_pause: <br> HIGH 11 <br> PAUSE 400 <br> LOW 11 <br> RETURN <br> Randi |
landmark Inner circle within a triangle 5194 Posts |
That's easy for you to say . . .
Click here to get Gerald Deutsch's Perverse Magic: The First Sixteen Years
All proceeds to Open Heart Magic charity. |
Cliffg37 Inner circle Long Beach, CA 2491 Posts |
For the record, I wrote my first successful program in basic back in 1985. It was a program that asked you for three numbers a, b and c... Then it gave you two possible solutions using those numbers to solve a quadratic equation. This was harder than it sounds becasue a quadratic formula can come to a point where it calls for a square root of a negative number, and the old computer would freeze up if that happened. I had to write a sub routine that checked for that first and had the computer report the problem without actually getting to that freeze up section of code. I was very proud of it.
Magic is like Science,
Both are fun if you do it right! |
Cliffg37 Inner circle Long Beach, CA 2491 Posts |
Btw Randi, the code you typed in above makes perfect sense to me. I think I will be able to handle it.
Magic is like Science,
Both are fun if you do it right! |
randirain Inner circle Fort Worth, TX 1650 Posts |
The BS1 is the cheapest, so you will probably run into it.
I use it in one of my tricks that makes it look like a hedgehog is shredding newspaper. I have a 3 chamber tube with a blower under it. I can switch chambers and make it toss confetti in the air three times. Here is the code that makes it work and I explained each part. Code:
<br>' {$STAMP BS1} <br>' {$PBASIC 1.0} <br> <br>' make lCount a variable <br>SYMBOL lCount=B1 <br> <br>'set pin 5 as an input pin. <br>INPUT 5 <br> <br>'Set pin 6 & 7 TO LOW, no voltage. <br>LOW 6 <br>LOW 7 <br> <br>showOn: <br> 'Set a loop and make pin 7 toggle between high & low, making an LED blink signaling "ON". <br> FOR lCount=1 TO 20 <br> HIGH 7 <br> PAUSE 50 <br> LOW 7 <br> PAUSE 50 <br> NEXT <br> <br>workLoop: <br> 'Main loop waiting for button to be pushed, which makes pin 5 go high. <br> IF PIN5=1 THEN blower <br> PAUSE 20 <br> GOTO workLoop <br> <br>blower: <br> 'Make LED blink again for 7 seconds. <br> FOR lCount=1 TO 28 <br> HIGH 7 <br> PAUSE 125 <br> LOW 7 <br> PAUSE 125 <br> NEXT <br> <br> 'Turn fan on for 1.25 seconds. <br> HIGH 6 <br> PAUSE 1250 <br> LOW 6 <br> <br> 'return to main loop and wait. <br> GOTO workLoop <br> This all should get you started really fast. Enjoy, the Basicstamps are awesome! Randi |
gdw Inner circle 4884 Posts |
Ah, thank you for that Randi. Makes more sense now.
"You may say I'm a dreamer, but I'm not the only one."
I won't forget you Robert. |
The Magic Cafe Forum Index » » Not very magical, still... » » P-Basic (0 Likes) |
[ Top of Page ] |
All content & postings Copyright © 2001-2024 Steve Brooks. All Rights Reserved. This page was created in 0.04 seconds requiring 5 database queries. |
The views and comments expressed on The Magic Café are not necessarily those of The Magic Café, Steve Brooks, or Steve Brooks Magic. > Privacy Statement < |