Let's Make Robots!

Programming With 12Blocks

Control a Servo with a Ping Sensor in about 5 minutes

When I did the Web Clicker, I picked up a copy of ViewPort for debugging and it was a lifesaver.  ViewPort was designed by Hanno Sander.  He also developed an alternate IDE for the Prop called 12Blocks.

I first saw 12Blocks at the Propeller Expo in Ohio last year & I dismissed it as a kids toy: great for blinking an LED, but not enough flexibility to do 'real' projects.  Last week, I took a second look at it and was very surprised.  It's a lot more useful and powerful than I expected.

What Is 12Blocks?

12Blocks is an alternate IDE for the Propeller.  It lets you lay out your code in graphical blocks so you don't need to worry about the idiosyncrasies of a programming language and you can focus on the program logic.  I've been playing with for a few weeks now and I really like it for a few reasons;

  1. It's still Spin Just hit CTRL+U and you can view / edit the code.  You can also import your own Spin objects
  2. Built-in Debugger ViewPort is integrated with 12Blocks so you can see how variables change, the state of pins, and send terminal commands.
  3. Tons of Blocks There are blocks built in for stuff like LCD displays, VGA, speech synthesis, and more.

I think it's useful for beginners who have never coded before or are new to spin.  It's also great for prototyping user interfaces and graphical displays - getting video graphics running on the prop is a little obtuse, and this makes it super-simple.

If you've got a Propeller Platform, Protoboard, Demoboard, or whatever, grab a copy of 12Blocks and follow the video above -  I'll show you how to make your first program.  My program notes are below.

Your First Program

First, familiarize yourself with the 12Blocks UI:

Whole 12Blocks

On the far left are the block libraries:

Libraries

Click on each rectangle to reveal each block in the library.  Control contains 'start' 'stop' 'IF' and the like.  Graphics is for TV and VGA displays, motion is for motors, and so on.

In the middle is the program area:

This is where you'll create your program.  Programs begin with a 'Start' Block.  If you want a program to end, you'll also need an 'End' block, both are in the control library.

The right is for ViewPort debugging:

By default, this area is hidden.  Just click on the Values, Pins, or Terminal boxes on top to make it appear.

Here's your first program;

If you have any trouble finding the blocks, note that they're color coded - the black blocks come from the black 'motion' library.  Also, you'll see values in yellow on the blocks.  In the Servo Block, the 4 = the pin the servo control line is connected to.

Your Second Program

Second Program

This first sets a variable (x) to the distance measured by a ping sensor, then if X is > 100, it sets x to 75, otherwise the measured value is used to ramp a servo connected to Pin 4.

Next Steps

There are plenty of additional blocks available in 12Blocks and you can even add your own code. I'm pretty impressed so far, download it and give it a whirl!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

 I reciently been studing the propeller and learned of 12 blocks. It now supports PICAXE too they mention.

 Logo

Babuinobot is a project to make Arduino's programmable with LOGO in a similar graphic environment. Unfortunately it looks like it is still in its infancy. It is free and open source.

Here are some links:

http://www.instructables.com/id/Cheap-Easy-Robotics-for-the-Non-Programmer/

http://home.teleport.com/~babuinobot_a/id5.html

I am currently building my first robot along the lines of the LMR Start Here with an Arduino, and was considering making it Babuino compatible, so my 7 year old daughter could program it. If it was as polished as this is, it would be a no-brainer.

Is anyone here using Babuinobot?

No, 12Blocks is closer to MITs scratch than anything else. it only works on the Parallax Propellor based controllers

As of today, at least, if you have an MSR1 based robot, such as the parallax Stingray. You can select the Stingray as a device and run with the appropriate motor drivers once they are installed. Installation involves copying three files into the 12blocks directory structure. Will be doing more testing on it tonight. Will release details in next day or two.

As of the prop expo at the end of august, a new version has been released

By the way, Bender uses 12 blocks as does its little brother, BJ

Was this sponsored?  Because nowhere did you disclose that you have to pay for the full version.

No, this was not sponsored.  And yes, this is not freeware.  There is a 30 day trial, though.

And the paid version has more features than the trial does.

While it is not freeware, there are two price tiers; There is the trial version which is a 'lite' version and there is the full version, which supports arrays and other functions. I recommend getting the full version if you are at all serious about programming robots using the propeller.

By the way, I'm just a paying customer but I'm in regular contact with the author so I do benefit from the relationship. I just don't get anything when anyone else uses it. (except for some satisfaction of knowing that more people are using a great tool)