Slide Potentiometers and Breakout Games

I like Arduinos – I tell my students that an arduino is a tiny ‘robot’ brain. Later on in the course I explaint to them that teachers lie all the time, because they can’t handle the truth…

Scratch for Arduino (S4A) is a variation of Scratch written to allow it to communicate directly with an Arduino board. Why would you want to do that? I hear you ask. Because you can tell Scratch to respond to a wider range of inputs than with a Picoboard or Makey-Makey. Plus, Scratch can then send instructions to servos, motors, LEDs and more to switch them on and off.

So, how long does it take to connect a slide potentiometer to S4A and write a simple Scratch Breakout game?

A slide potentiometer connected to an Arduino

It took me a few minutes to hook up a slide potentiomwter (cost – CZK37 – less than US$2) to an Arduino using some jumper wites and alligator clips I just happened to have lying about the place. The code took a couple of minutes – I wanted to do something reasonably straightforwards that a student could do using a little bit of trial and error.

Here’s the scripts.

The script for moving the paddle
The script for moving and bouncing the ball

And here’s a screenshot.

A screenshot of a very simple Breakout game – what would you do to improve it?

If you want to try this for yourself, and you’re free on May 18 in Prague – come and visit us at Scratch in Control