×

Our Technical Support team will be out of the office on Wednesday, April 23 starting at 12pm. Tech Support will reopen with normal hours on Thursday, April 24 at 9am. Thank you

Enginursday: Visually Programming Arduino


I got my first taste of programming with RCX Code and an old Mindstorms RCX 1.0, so maybe it’s nostalgia speaking, but I really admire visual programming languages for their ability to introduce younger folks to programming. With color coded operators, geometrically shaped data types, and no semicolons (!), visual languages have a unique ability to make programming a more intuitive experience. And with the (admittedly necessary) annoyances of syntax removed, more of your programming focus can be directed towards solving the actual problem.

On the National Tour, and just browsing the Internet, this is a form of programming I’ve been encountering a lot lately. So, in this week’s Enginursday post, I wanted to introduce a couple of exciting visual programming tools that are specifically geared toward the physical computing we love.

ArduBlock

A month or so ago, a coworker of mine (hi Brian!) showed me a beta release of ArduBlock. ArduBlock is a programming environment designed to make “physical computing with Arduino as easy as drag-and-drop.”

ArduBlock Screenshot

It’s really neat how ArduBlock ties the visual, drag-and-drop programming into actual Arduino programming. The software acts as a “tool” for the Arduino IDE. After drawing up your sketch and hitting upload, the software simply parses your block diagrams and turns it into real Arduino code. Then it compiles and uploads to your board normally. You can scroll through the generated code, compare it to your visual code, and even make your changes there. It has a lot of potential to be an amazing educational tool.

ArduBlock gets bonus points because it’s an open-source project, with development ongoing (last commit days ago!). In less than a month, the software has grown by leaps and bounds. It’s a project that’s continually improving. If you’re looking for a nifty, graphical alternative to Arduino programming, I’d encourage you to check ArduBlock out!

On the National Tour, I’ve had a few chances to see ArduBlock in action. In a workshop last weekend at the (seriously amazing) ‘Iolani School, we had the opportunity to lead both teachers and students in programming the LilyPad ProtoSnap Dev Board using ArduBlock. The workshop was a great success – seven hours of programming, zero compiling errors. It didn’t take much instruction before the students quickly took off on their own, creating cool projects like a tap-input metronome, “monster detector,” or a miniature police siren. ArduBlock allowed the kids to focus everything they had into creating rather than debugging, and that’s what makes visual languages so special.

Scratch For Arduino

There are a a variety of visual languages out there, and Scratch is near the top of the list, turning kids into budding animators and game designers. But (unless you have a PicoBoard) it’s tough to integrate with LEDs, motors, real-world sensors, and the like. Enter Scratch for Arduino

S4A is a forked version of Scratch proper. The sprites and animating tools are still there, but there are also digital/analog I/O blocks, motor controls, and streaming updates from the analog inputs.

S4A Screenshot

S4A differs quite a bit from ArduBlock. It uses a firmata-type of protocol to interface between actual executed code and the Scratch program you’ve drawn up. There are pros and cons there: Written code takes effect instantly, but you’re always tethered to the USB port. For any kids who are already better Scratch creators than I’d ever be (which is a lot, judging by what we’re seeing on the tour), S4A is a perfect sidestep over into the physical world.

Thoughts?

Visual languages aren’t for everybody or every situation. As a “text” programmer, learning ArduBlock proved frustrating at times. There are some constraints (the “repeat”/for loop can only initialize a variable with value 1, and increment by 1 each time) and annoyances (arrays references begin at 1 instead of 0) to get used to, just as with any language. But they still seem like an amazingly powerful tool to introduce beginners of all ages to programming and critical thinking.

Are there any other visual programming tools out there we could be using alongside S4A and ArduBlock in our educational pursuits (Labview?)? With tablets, and touchscreens taking the world by storm, are graphical languages something us text-programming dinosaurs need to adjust to? Any other thoughts on the subject?


Comments 37 comments

  • Not hating, just saying - I’ve been watching “visual” programming systems come and go for almost 40 years and so far everything serious is still done textually.

    I think that the reason for this is that it’s just as difficult to come up with an intuitive visual representation as an intuitive textual one, especially if you’re trying to represent interrupts, events, exceptions, function parameters, etc. Probably the best visual language so far, at least in terms of being a good match for the problem being solved, is good old venerable ladder logic. It is a visual layout of the arrangement of input and output signals and all the logic used to map one onto the other. It can even be directly implemented in hardware with switches and relays. But…

    And that brings me to my second point … it’s still incredibly easy to write poor, obtuse, unreadable and undebuggable code even with a language that matches the problem so well. And when the problem space is expanded to handle complex situations that are controlled with PLCs, the language stops matching the problem and the code structure gets harder to control.

    Basically, the problem is what LightManCA is alluding to - visual systems aren’t easier for newbies and “civilians” because they’re visual, it’s because the problem space is limited to the easy stuff. Once you have to expand beyond that, no matter what programming model you use, you’ll have to be trained and think.

    The ultimate easy programming environment was once thought to be natural language. Anyone who’s ever listened to the “Who’s on First” schtick should be able to see the fallacy in that. But some government software types decided to go with it anyway. They came up with a language where instead of “x = y + z” one had to type in “ADD X TO Y GIVING Z” and thus was born COBOL. Anyone who’s suffered through reading long COBOL listings knows just how unreadable the stuff usually is.

    The long and short of it - a limited language will only let you code limited solutions. If you can live within those limits (like using the language to expose kids to the fun of computers), great. Just expect to outgrow the language one day.

    • I agree, text programming is way more powerful. But after also having gotten back from the SFE tour, when you are trying to teach a room full of kids to do something they can see in 1 class period, or 1 Saturday afternoon its a great tool. It allows all the kids (not just the ones who aren’t intimidated by computers and coding), to see structure and understanding the idea of coding independent of syntax. Having 3rd graders go from not knowing anything about programming to making a game by themselves in a couple of hours is something you just can’t do with text based coding. This isn’t enough to get them a job coding, but hey, they are in 3rd grade which is still a bit early for the job market. Getting them interested in coding and getting them to understand the flow of coding can be done quickly and easily this way. Again, great tools, but not a replacement for text based programming.

    • I would have to disagree with the statement that everything serious is done textually. I have done quite a bit of work with Labview over the past 10 years and have seen projects with 1000+ hours of development, involving multiple developers, that when finished ran complex systems of computers and other hardware. I am not saying that a solution using a text based language could would not have been plausible, but the development of the project did not seem to be severely limited just because the language was a “visual” programming language.

      That being said, you are correct that there are definite limitations to visual languages, including Labview. There are many things that can be done in C, C++, etc (which I use more frequently than Labview) that simply do not lend themselves to a visual programming solution. I just thought it was worth saying that some serious projects can be accomplished with a visual language without (at least in my opinion) being severely limited by the development language.

    • The ultimate easy programming environment was once thought to be natural language. Anyone who’s ever listened to the “Who’s on First” schtick should be able to see the fallacy in that. But some government software types decided to go with it anyway. They came up with a language where instead of “x = y + z” one had to type in “ADD X TO Y GIVING Z” and thus was born COBOL. Anyone who’s suffered through reading long COBOL listings knows just how unreadable the stuff usually is.

      I did a couple of years in the early 2000s at a state college in Nebraska where the CS curriculum still focused on COBOL and IBM mainframes. I was just bumming around taking general credits and art classes, but friends of mine were on a CS track. Looking over their homework always brought on a certain amount of sympathetic despair. That said, maybe it’s worth pointing out that it probably still runs a substantial fraction of the world economy in 2013. COBOL’s an evolutionary dead end in a bunch of ways, but it owned a lot of the territory for a while.

      I’ve spent time with languages that did their best to read like English prose. HyperTalk always comes to mind. HyperTalk was a terrible language, really, but HyperCard was a pretty amazing software environment, and it sure did a lot to draw me personally into programming. Despite being focused on a visual, point-click-drag mode of authoring that’s at least theoretically the aesthetic opposite of the tools I’ve come to rely on in my working life. There’s still nothing quite like it, though it’s been influential all over the place.

      I tend to doubt that “visual languages” will function as much more than toys until they’re composable, easily manipulable representations of complex abstract syntax trees that can also convey rich semantics at a glance. That’s a tall order for anything that wants to compete with all the cognitive and cultural advantages that written language, meaningful names, and quasi-mathematical notation already carry.

      Still, it’s not like I mean “toy” as a disparagement. If this stuff offers a welcoming surface for beginners, more power to it. If it points in the direction of richer tools for understanding code in the general case, so much the better. We need all the help we can get.

    • I agree that a lots of visual programming languages have come and go and none stick. One problem is to insist the visual programming language to be “full” programming language. Ardublock doesn’t try to be that. One of the design philosophy is as a gateway environment to eventually lead those really interested into “text” based programming. That’s why Ardublock tries to generate clean C/C++ codes.

      Kids use picture book before they accumulate enough understanding of the text to real everything in simple text. Ardublock is designed to be picture books of programming and allow more people interested in simple programming without the need to overcome the barrier of entry to text base language. “Syntax error” really frustrates beginner.

    • Visual Programming is just a higher level of programming. You may not have the low-level control you ‘think’ you need, but what visual programming does sometimes is optimizes your application. “There are many ways to skin a cat” comes to mind when using lower-level languages to develop applications, and there are many ways code inefficiently or even dangerously regarding resource consumption and other common pitfalls in very complex application development.

      Visual programming will be the future in industry, because it achieves optimal and repeatable solutions with a reduced amount of development time (often termed ‘rapid prototyping’). This also allows for faster software validation and modular software changes.

      Applications where personal safety are concerned (vehicle power-train controllers) are moving toward this method of development. Does it make sense to ‘visually’ program a controller to blink an LED? - probably not… but as complexity goes up, it becomes invaluable tool.

      Just my 2 cents

  • Ive always written off the possibility of learning to use arduinos(and anything else requiring programming) because i find written languages to0 unwieldy and difficult to learn. I wasnt even aware there was such a thing as visual programming. This is a door opener.

  • Ardu block looks promising!

    One thing about having a drag and drop programming interface is that at some point in time even beginners can run into something where they want to do something that the interface wasn’t designed for. If you can edit the code afterwards that would solve that problem…. Often getting started in programming is hard (getting layout and structure, etc), but if you just want to modify a line or two, that'’s easier.

    I’ll have to see if this is more enticing to get my wife into fiddling with arduinos. I’m to used to seeing code to have it something I’d want to use, but great for others.

    • I was going to reply about how I loved using Delphi 1.0 in the early 90’s on Win 3.1, the first graphical event driven code, where you just double clicked on a graphical item, it generated code, and you just put some code into the handler for that object.
      The I thought how cool it would be for the scenario you just described.
      30s later in Google, I find http://www.state-machine.com/arduino/

      • Event driven?? I need to check that out! One of the things I understand the least is handling interrupts and using timers. So powerful, but definitely a level up than regular programming (especially since the ATMega does not natively support multiple tasks, at least not from Arduino).

  • Hi! There is another beautiful and simply software to program arduino in good and old Ladder and STL languages: http://www.autoware.com/alt :)

  • I despised LabVIEW when I first saw it in one of my engineering courses. After being forced to use it, I am an absolute die hard LabVIEW fanboy. I drank the KoolAid and am even CLAD certified.

    I would love being able to program an arduino with LabVIEW. Last I checked though, you can only interface with it. (You have to remain tethered to your PC and can’t actually upload your code to the arduino.) I am currently working on a way around it, but haven’t had time to seriously explore it. Until then, I don’t find it to really be a viable solution.

    This makes me incredibly sad.

  • One word to all the graphical haters out there…FLOWCODE. Muahahaha. Works great. Generates code quick. Handles everything a context language does.

  • If you would like 100% visual, check out LabView with National Instrument. The post is still partially text but using colored symbols instead of alphabets.

  • There is a way to use LabVIEW for this, and it has some pretty decent community support. I’ve used both and happen to prefer C, although they both have their ups and downs. http://sine.ni.com/nips/cds/view/p/lang/en/nid/209835

  • Ardublocks looks interesting, though I’ve never been impressed by Scratch. My daughter took a class that taught it at school, but it becomes apparent quite quickly how limited it is. What’s the point of a toy language you have to throw away the second you want to do something real?

    A component based system could work nicely on Arduinos, but it will be interesting to see how semantic limitations affect your code on such a resource limited system. Troubleshooting that could be a nightmare.

  • When I started getting into micros a few years ago, I couldn’t have identified a line of C if you had hit me over the head with it. I tried hard to find a concise, readable guide to Arduino programming. There are a lot of sites that have command lists and snippets of “Hello world!” code, but I’ll be darned if I could find a clear bottom-up tutorial for the total noob. If there is such a thing, I’d be thrilled to see it.

    I ended up abandoning Arduino in favor of PICAXE. Their Logicator software makes program development – at least for the relatively simple stuff I’ve been doing – a relative breeze. Their whole environment is geared to education and getting kids started in physical computing, so it was perfect for a 40-something hobbyist whose last experience with programming was making an ASCII rocket scroll up the screen on a Commodore PET in ~1981.

    I’m invested in PICAXE now, with a supply of chips, proto boards and programming cable, but if I were starting over, I would definitely try ArduBlock or Scratch. They may not have all of the flexibility that’s afforded someone with a full command of C, but it sure looks like they would ease entry to the hobby for a beginner of any age,

  • Now will it run on UDOO?

  • one powerful item in my opinion, when using a tool such as ardublock etc one can learn from reviewing the code generated and then figure out how to modify the code to do what is needed. hopefully the generated code is such that it is easy to follow and generates the correct code for the function needed/expected. how many times have “we” borrowed code that does a similar function and modified it for our own use…. every day!! lol

  • LabVIEW of course. It’s the next step up from Scratch for a general programming environment. It’s not Freeware but you can get a student edition for $50 or the LabVIEW for LEGO MINDSTORMS which would also work for less than $200.

    For text programmers who aren’t able to handle icon based flow diagram programming there is also RobotC for education. (Just kidding) Traditional text programmers are notorious about their dislike of graphical languages.

    You can do just as serious work with LabVIEW as most other languages. Yes, as you progress you need to understand software engineering like with any other program. Most people who think LabVIEW isn’t a serious progam environment haven’t spent much time with it.

    I’ve been working with it for close to 25 years. I can get a n 8 year old kid to program and in the same environment I’ve seen large Systems at places like CERN done in LabVIEW that I can guarantee you are highly serious.

    If I put 20 students in a room and can get them all doing some programming and understanding what they are doing and getting exited. If I did that with a text language MAYBE 5 would get interested, the rest wouldn’t understand what is going on and decide that they want nothing to do with programming. I work a lot with students at schools since many years and in a classic text language you just won’t get many of them interested.

    Each language has it’s advantages and disadvantages as Brian pointed out before but to say LabVIEW cannot handle “serious” Programming is incorrect. LabVIEW has been around for over 25 years but it’s focus is on robotics and measurement systems not designing a new database or a website. It hasn’t come and gone. It is still growing and has never stopped. I guess it depends on how you define what is “serious programming”.

  • Ladder Logic. As someone who writes long, complex PLC programs for manufacturing facilities, I’ve always thought of Arduino’s as little toy PLCs. Naturally, I think it would be interesting to have a simple Ladder Logic editor, or Function Block, or all the IEC 61131-3 languages. I daily switch back and forth programming the same types of controls in Ladder and Structured Text and while text is much more compact, I find I can grasp a line of logic more quickly seeing it in ladder, as opposed to the exact same line in text.

    But visual programming is only half the benefit, visual debugging by watching your code execute in real time is much nicer in ladder than in text. At least with most PLCs, this ability is available in either language. As far as I know there is no way to watch Arduino code execute. Ladder, combined with the ability to watch code execute in real time would go a long way to helping people learn to program.

    Lastly, Ladder Logic is sometimes seen as simple, but more advanced editors support: arrays, structs, subroutines, functions, objects with methods & properties (private & public), pointers, interrupts, events…

    • I agree, programming with PLC like languages would be quite interesting, especially to introduce people to industrial control programming at an earlier age. My question would be, can an arduino run “realtime” code like PLC’s do? This difference between PLC programming and controller programming confused the heck out of me for a long time. Also, I think if you dropped arduino programming environment and went with AVR studio or some integration between the two, you could do some pretty low level and high power debugging

  • Although I do like the idea, I think they end up requiring just as much thinking as just doing it in text. I do see the application of them where they would be nice for debugging and also introducing someone to it without overwhelming them with code. IMO though, I think Ladder Logic (PLC) editors are probably the best way to represent visual programming while still providing the user with control. I know there have been some advancements in porting Arduino over to Ladder Logic, but I think would be a good avenue to keep pushing into.

  • Also see modkit.com for another visual way to program Arduino…

    • Same here, modkit offers a client but even a browser based interface for visual programing. As i recall being one of the more popular derivatives i would also surprised to not even see it mentioned. Regardless, its more than worthy of a proper check out in this topic. http://www.modkit.com/

      • We actually have taught several classes using ModKit, as it supports the LilyPad main board, but it can be rather buggy in a classroom setting. It’s a useful tool, but needs some work to really become a preferred method for large classes.

    • I was surprised to see Modkit omitted as well. Especially considering Jeff and others were playing with/Demoing it at AVC last year… wassup ?

    • modkit is also a Scratch derivative (it’s where I first learned of Scratch). I wonder how it compares with s4a…

  • You may check www.mindplus.cc another visual programming tools.

  • Simulink!!!!!! Seriously, programming, data recording and data analysis all in Matlab. Doesn’t get much better than that

  • I’m of a couple of minds here. Anything that get people (kids or adults) interesting in programming and electronics is good in my opinion. Anything that makes it easier for someone to implement an idea they have for a widget, piece of interactive art, automatic cat herder, or whatever you have cooked up is also good. Things like visual programming and arduino certainly facilitate interactive art and such things and open up the world of custom algorithm implementation to none programmers. It does not make you a programmer. Actually, I consider a programmer to be a step below in the talent spectrum. All you need to do to “program” is learn the language syntax, whatever the language. Visual programming focusing on algorithms or program function.

    My big beef with visual languages, and even the move to higher and higher level languages is that it makes it easy to accomplish things in a bad way and so we end up with multi-ghz processors being needed to flash a few LEDs. I’m thinking of the penchant for using Raspberry Pi’s in place of arduinos because you can run in a normal Linux OS environment. That’s fine for some hobbyist at home, but it works its way into the commercial environment and suddenly your toaster has to run embedded linux so a two bit java developer can write the code that lets your burn your bagel in the morning….

  • It wouldn’t be much of a leap for me, as I use LabVIEW, which is graphical, but sophisticated when you start digging.

  • I don’t know if it’s just me, but that actually looks more confusing than a written language. Of course it may be easier for people just getting into programming. I dunno.

  • Love s4a however it does not work with the new version of scratch 2.0 would love to see something like that!


This Week

This Month

Heartbleed

Happy Arduino Day!