Shop OBEX P1 Docs P2 Docs Learn Events
S3 and BlocklyProp — Parallax Forums

S3 and BlocklyProp

WhitWhit Posts: 4,191
edited 2016-09-19 21:39 in Robotics
The S3 plays with its ancestors using this Ping))) ultrasonic sensor hack to the Hacker's Port and some nifty BlocklyProp code from Ken Gracey.



Here is what Ken's BlocklyProp code looks like - the neat thing about Blockly code is that it explains itself - take a look (I did modify the if do minimum distance in the video example above so the S3 would turn before bump its next of kin!).

KenPingCode.JPG

The loop repeats forever. A variable named distanceCM is set by the green block that measure distance in cm from a PIng))) on pin 5. The play tone uses that variable multiplied by 5 to create and play a tone. Motor speeds are decreased as the distance to an obstacle decreases. If the minimum allowed distance is reached, then the S3 rotates 180 degrees and the cycle begins again.

This complex bit of coding is a breeze with BlocklyProp! Give it try!
631 x 427 - 57K

Comments

  • David BetzDavid Betz Posts: 14,511
    edited 2016-09-20 01:41
    What is the purpose of playing a tone of zero Hz?
  • You can mix two frequencies, and he's only using one and the second tone wasn't used.
  • WhitWhit Posts: 4,191
    Ken Gracey wrote: »
    You can mix two frequencies, and he's only using one and the second tone wasn't used.

    He? You mean you! Great little program by the way - One of the few times my wife had been impressed by something with my robots. ;-)
  • Ken Gracey wrote: »
    You can mix two frequencies, and he's only using one and the second tone wasn't used.
    So if you don't specify a second frequency of zero you get whatever frequency was played on that channel the last time? Or maybe some random frequency?

  • David Betz wrote: »
    Ken Gracey wrote: »
    You can mix two frequencies, and he's only using one and the second tone wasn't used.
    So if you don't specify a second frequency of zero you get whatever frequency was played on that channel the last time? Or maybe some random frequency?
    Never mind. I see that both frequencies are part of the same block. That makes sense now.

  • You might have pointed out something we need to address. This block could probably use more clarity in the description so people understand it's capabilities.
  • ercoerco Posts: 20,254
    edited 2016-09-23 17:56
    Ken Gracey wrote: »
    You can mix two frequencies...

    So we can simulate DTMF and 56K modem sweetness! Need to put these $10 water speakers onboard S3.





  • That programming language looks more like scratch to me....
    --
    Strange... Erco why are your robots visiting a location closer to your state capital?
  • They will probably look very similar now.

    Scratch and Google Introduce Scratch Blocks
  • It looks like the motor speed is expected to be in the range -100% to +100%, and it's going to get set to a number from +4 to +635. So I assume that it's clamped to a max of +100%? It seems nice that people don't need to worry about having a different sign for the left and right motors.
Sign In or Register to comment.