- By: Ken Gracey Published: 13 June, 2014 1 comments
The BASIC Stamp’s PBASIC syntax is an effective language for a first experience with embedded electronics. Teachers and young students need early success, especially when we combining electronics, microcontroller programming and sensors. There’s plenty of opportunity for things to go wrong with any of these pieces, so choosing a simple language only increases the chances for success.
As educators, you know that students come into a robotics class with big expecations and enthusiasm. We need to capture and sustain their enthusiasm so that it has career potential, dosing out the right mix of education with reward and failure. Their attention span is getting shorter as a result of iPhones and instant feedback, so a casual sign and glazed look could be the end of interest as they check out for other activities. Making sure they're learning an easy programming language ensures a higher potential for success.
Therefore, a first programming language experience must be fun and easy!
Last week I taught a group of 14 middle school students (12-13) on their “robotic odyssey” using the Boe-Bot – an in-depth immersion on robotics, electronics and programming. The pictures above are from our course. My local school district is a Parallax test bed and the Superintendent is comfortable with this concept. I try everything Parallax offers on these students.
Over the past four years I’ve given over 500 hours as a volunteer. I’ve also worked with students in China, Taiwan, USA and Europe. I volunteer because I really enjoy sharing robotics with students, but maybe more importantly I gather lots of insight about what it really means to make educational products.
An engineer should be able to program and learn multiple languages to be effective in a career. Choosing the right tool depends on the job. Chip Gracey must use Verilog to design the Propeller 2 and Andy Lindsay will leverage C libraries to make the ActivityBot do impressive tasks concurrently. While I’m not claiming PBASIC to be your industry language, I think it's an ideal first step that prepares them for the next. Our education team has built a nice transition to C with our Simple Tools libraries that have functions that match many PBASIC commands.
Back to the middle school kids and their first experience with PBASIC. At this age the goal is to successfully assemble, program, breadboard, modify and write code to make the robot do what they want. Over and over, students learn enough PBASIC in a few days to compete in a robotics contest. These are the benefits I've seen:
- Immediately visible results. Each PBASIC command does something, usually having a physical I/O pin result the student can see, like a motor moving, an LED lighting up, or seeing the value from a sensor. I find PBASIC almost low-level in this way because it puts a student in a stronger position to really understand more abstracted code later, appreciating all those "communication details" managed somewhere else.
- Single-threaded design of PBASIC gives a student a real low-level introduction to hardware control with a high-level language. Using servo control as an example, nothing can be hidden. Motor pulses must be sent regularly every 20-50 ms. This teaches efficient use of limited resources and the real communication needs of the device connected to the microcontroller early on. I admit that there are limits to these kinds of useful lessons, too. Writing a synchronous serial routine to interface to a sensor is an unnecessary engineering exercise for an early learner. While this is made very easy in C through library support, these codes can also be tucked into a subroutine in PBASIC and accessed by a single command.
- Quick code debugging by teachers. In their first experiences, students quickly say “Ken, it doesn’t work!”. Teachers can certainly have one student help another, but at some point you’ll need to take class time to give their code a quick look. PBASIC is easy to review in this way - it reads like English. Students will make simple mistakes in their syntax, like incorrect spelling. After all, they’re still learning to type.
No teacher should take language choices too seriously, by the way. It was just a few years ago that it looked like Java would be the “favored” language in California schools. Programming languages stay around for a long time, but it’s common for the popular language to shift around as time passes. Customers on our forum talk about their early experiences with FORTRAN, FORTH, PASCAL, Assembly, and a long list of other languages.
Since Parallax supports PBASIC, C and Spin we assembled a small comparison of those we offer to help you evaluate at our brief Microcontroller Language Options.
There are also arguments against BASIC as a first language, like the famed GOTO and the spaghetti code it creates. My thought is that if you've created PBASIC code you can't easily follow it's probably time to move into an object-oriented language. Sometimes these early comparisons can be shown with side-by-side code examples during a break.
So how did the middle school Robotics Odyssey course end up? Really well! The students programmed for three full days and competed in our Individual Pursuit Race with their own code. During breaks we flew quadcopters, programmed Arlo robots, and showed the younger students our projects. The modifications to the robots included big wheels, scoops, sensor fixtures and personality.
As these middle school students grow they’ll work for Parallax. This summer I’ve hired four high school students to help us lay the foundation of the Unmanned Aerial Vehicle Educational Program. Each of them will build and document an ELEV-8 project of their choice. Although the middle school kids are too young to work for pay, I told them they can come over to work with the high school kids on the quadcopter projects.
If you need any help choosing a Parallax product and a language, just drop us a line at firstname.lastname@example.org and tell us the best way to contact you. You will receive a quick reply from Andy, Stephanie, Courtney or myself. We also know how it feels to stand in front of a class of students. Nothing is as deflating as ending a class with confused students, yet there’s no reward as high as them not leaving the classroom for lunch!