Category Archives: Programming Languages

Programming Languages and Raspberry Pi

There are two programming languages that are popular for use with the Raspberry Pi computer.  The first is Scratch which is a visual programming language.  The second is Python which has a more traditional approach, with text-based language statements, and use of a text editor interface for program development.

Last year, the Rutland Tech Club hosted two Scratch programming events.  Scratch is a visual programming tool developed by MIT.  The programming language constructs resemble “Lego” blocks which can be snapped together on the computer screen to build programs.

On the Raspberry Pi computer, the Raspian Linux operating system it comes with it’s own custom version of Scratch.  This version of Scratch allows access to GPIO connections on the Raspberry Pi, which are the general purpose I/O or input/output connections.  That means you can access external input sensors and output devices which can be connected to the Raspberry Pi, via the GPIO connectors.  For example, you can instruct Scratch to read in a sensor input (i.e. motion sensor, temperature sensor, etc.) or send output command to output device (i.e. camera, LED lights, etc).

Python uses the more traditional form of programming, using text commands and statements, where the programmer must input the proper program language syntax in order to instruct the Raspberry Pi what to do.  Python is a popular computer language, which has some interesting syntax features.  Unlike other computer languages, the “if” statement (conditional, if – then – else), does not use curly braces “{” and “}” to delineate the statements within an if code block or else code block.  Instead, Python uses consistent code “indenting”.  This can make for a more readable program.  In other words, program whitespace or indenting is critical in Python, whereas in other languages, proper use of whitespace is not critical (although highly recommended for readability).

Just as in Scratch programming, you can use Python to access GPIO connections to input sensors and output devices.  The Python approach is text-based programming instead of Scratch’s visual programming method, but the same types of things can be done in both languages.

The Codecademy.com website is a good place to begin to learn Python.  The tutorials are grouped into units and also include some problem solving exercises to allow you apply what you just learned.

Whatever types of projects you want to do on your Raspberry Pi, having some knowledge of Scratch or Python programming is very helpful.

 

Advertisements

Next event, January 31: HOUR of CODE Challenge

Saturday, January 31, 2015, 1-3PM
Rutland Free Library, Fox Room (upstairs)
10 Court Street, Rutland, VT

http://code.org/learn

http://hourofcode.com/us

http://www.codecademy.com/

All ages welcome.  Bring your laptops.  We will do the Code.org “HOUR of CODE” challenge.

Learn the basic concepts of computer programming, using a fun visual approach.  If you have never done the Hour of Code, you can start with the HOC Challenge.  Using a video-game maze theme, build short computer programs to make Angry Bird catch Bad Piggie, by snapping together Lego-like program code blocks on your screen. Later on you can make the Zombie find the Sun Flower in the corn maze.  When you successfully complete the HOC, you will get an online Certificate of Completion.  We can help you save or bookmark your certificate image to your computer, so you can print it out at home.

HOC_view_code

In between the HOC exercises you can view video messages from Bill Gates, Mark Zuckerberg, Black Eyed Peas founder will.i.am, and NBA star Chris Bosh (he studied computer science in college).

If you have done the HOC Challenge before, you can go “Beyond the HOC” with additional exercises and challenges to learn more programming concepts on Code.org.  Also, for those who might be interested, you could also try the free tutorials from Codecademy.com, another free to use website to learn programming logic.

In 2014, we held two events around Scratch programming.  If you complete the Hour of Code and/or Codecademy, you will be ready to tackle Scratch programming, which has even more capabilities, and is also a visual approach to computer programming.

As Douglas Rushkoff’s book title says: “Program or Be Programmed”.  Learning to program is like learning another “language”.  It’s another aspect of “computer literacy”, writing programs, instead of just using them.

Tell your friends and family about the Rutland Tech Club.  This event is also posted on the Rutland Herald inViTe Calendar!

We look forward to helping you with the Hour of Code Challenge,

Ron, Steve and Chad

Scratch Program Demo: Rutland Halloween Parade Route

This project is a starter project, as it has some pre-loaded Sprites (Halloween cartoon characters), Background images of streets along the Rutland Parade route, and Audio sounds.  The initial code scripts for the Cat going along the parade route is there to give you some ideas on how the code blocks were put together.

Rutland Halloween Parade demo Scratch project:

Rutland Halloween Parade route

Scratch Project page:
scratch.mit.edu/projects/30959062/

You can copy this project and use whatever you like as far as Sprites, Backgrounds, Code and Sounds.  You can also add your own Sprites and Sounds, and use whatever Backgrounds you like.  Make the characters follow some or all of the parade route.  Have fun!

The background photos were captured as screenshots from Google Maps of downtown Rutland streets, which follow the annual Halloween Parade route (Strongs Ave. to Wales St. to West St. to Merchant’s Row to Center St.  The sprites are Halloween cartoon characters.  The programming challenge is to move your chosen character(s) through the Halloween Parade route.  Good luck!

Next Event: October 25, Learn Scratch Programming

The next event is on Saturday, October 25, 1-3PM, again at the Rutland Free Library.  We are going to do another hands-on event.  This time we are going to start working with a programming tool called “Scratch” from MIT.  For those who were unable to attend our first Scratch event back in April, this is your chance.  October 25 is also the date of the annual Rutland Halloween Parade (in the evening), so our Scratch programming activities will have a “Halloween” theme, as far as ready-to-go sprites for your Scratch program or animation.

Scratch is another visual programming tool / language.  For those of you who participated in an Code.org “Hour of Code event, you will notice that Scratch has some similarities to the visual programming approach of “Hour of Code”.  But Scratch has many more programming features, and introduces you to many more programming concepts and ideas.

http://scratch.mit.edu/

Scratch enables you to program your own interactive stories, games, sounds and animations.  You can also share your creations with others in the Scratch online community.  According to MIT’s website, “Scratch helps young people learn to think creatively, reason systematically, and work collaboratively — essential skills for life in the 21st century.”

At hour “Hour of Code” event back in February, one person had a question about “sprites”.  Scratch does allow you to have one or more sprites (visual graphics to represent people, animals, characters, things), that can be animated.

For each sprite, you can tell Scratch to do different things based on different “events”.  This is called event-driven programming.  For example, you could play a sound, or have a character say something in a cartoon bubble, if the user clicks on something, moves their mouse or presses a key on keyboard.  These mouse/keyboard events drive the action on the screen.

This blog also has some earlier posts regarding Scratch Programming.  Scratch is a very nice tool and way to learn and develop programs.

Hope to see you on October 25th to start to learn Scratch programming.

Ron and Steve

Upcoming events for Fall 2014

Just a quick update on this fall’s events that are being planned.  These events will again take place at the Rutland Free Library in the upstairs Fox Room, from 1-3PM on Saturdays:

September 13: Guest presenter is Chad Merkert, who will do one of these topics (still TBD): A) Tips on PC / data security and passwords, or B) using Linux in the context of an older computer, like a Windows XP (now unsupported), and how you can still make use of an older computer.

BTW, Chad also runs a local Meetup Group (VermontDev):

October 25: Scratch Programming.  If you did not attend our April event, here is another chance to get started with Scratch.  If you did attend in April, we can help you get started on other aspects and features of Scratch.

http://scratch.mit.edu/

https://rutlandtechclub.wordpress.com/?s=scratch

November 29: TBD, although I am thinking about an introduction to Arduino.  I went to SolarFest this weekend in Tinmouth, and there was a workshop on Arduino, which was very interesting.  The presenter at SolarFest was Jeff Molson from Ottawa, Canada.

http://www.arduino.cc/

http://www.solarfest.org/program/solarfest-2014-mini-maker-faire-workshops/

Have a nice summer, and I look forward to seeing you later in Fall 2014.

Ron

Young Hacks Academy Coming to Rutland in July

I recently found out through a Front Porch Forum email ad that there is a new summer camp which includes some computer programming skills training.  The camp is called Young Hacks Academy and will offer programs around Vermont this summer, including two weeks in Rutland.

The YHA uses Scratch programming (MIT Media Lab) to teach some basic programming, logic and problem solving skills.  This is the same programming tool that we covered at our recent RTC event in April.  Anyone wanting to learn more about Scratch programming should check out this learning opportunity.  YHA is coming to Rutland the weeks of July 7 – 11 and July 14 -18.  The summer camp will take place at Christ the King School.  For more info, check out the YHA website.

BASIC Computer Language’s 50th Birthday

This morning I heard a NPR radio story about the BASIC computer language’s 50th year celebration.  Yesterday, Dartmouth College celebrated by hosting a BASIC @ 50: The Future of Computing panel discussion.

Wow!  When I learned to program in BASIC around 1974-75, BASIC was not even a teenager yet.  I’m a few years older than BASIC, but I am still amazed at the journey from teletype machines to smartphones.

BASIC stands for Beginner’s All-Purpose Symbolic Instruction Code.  This computer language was developed with the intent to be able to program remotely on a teletype, via dial-up to a Time Sharing computer.  BASIC was developed by two Dartmouth College professors, John G. Kemeny and Thomas E. Kurtz.  Prior to the development of BASIC, Professor Kurtz would have to drive 125 miles to Boston to use a computer at MIT.  The turnaround times could be a week or two, and if you made programming error(s), you could lose weeks of time.  Also, BASIC did not require the use of punch cards.

The professors also wanted to allow people from other academic disciplines to be able to use computers besides the mathematicians and computer folks.

In the NPR broadcast, Dartmouth Professor Dan Rockmore recalled writing a poker game in BASIC.  When I was in high school, my parents celebrated their anniversary with a trip to Las Vegas.  They brought back a dice game, that was a mimic of a slot machine.  Based on the game instructions (my system requirements), I programmed a simple Slot Machine game in BASIC.  Back then everything was text (no images, non-visual).  So I had to print out the fruity names, “Cherry”, “Lemon”, “Orange” on the roll of teletype paper (sorry no Photoshop images or clip art GIF files back then).  But I was able to make the teletype’s “Bell” ring, “ding, ding, ding, …”, when you had a good combination of matching fruit.  I even kept track of how much virtual money you still had, and how much you won or lost on each play.  As the teletype printed out the Slot Machine fruit names, it would bounce slightly across the floor whenever the carriage return went back to the left.

Today the closest thing a smartphone can do is “vibrate”.  But smartphones will never be as loud as a teletype!

BASIC went on to be ported to minicomputers and microcomputers (personal computers).  Microsoft’s Visual Basic was influenced by the BASIC language.

Happy Birthday BASIC!