Monday, September 19, 2016

Parallax S3 with Ping))) Hack

The S3 plays with its ancestors using this Ping))) ultrasonic sensor hack 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 it bumps its next of kin!).
  

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!

No comments:

Post a Comment