Tag Archives: Arduino

The power of variables – making music easy in KS2 coding

Variables are really useful – as the name suggests, they can vary. When you make a simple change in the variable, the result can feed through a program rather than you having to type it in everywhere.

So for music, we have developed a function. In functions, you can “send” details to a function and it will carry it out for you. It saves you having to keep typing the function again and again.

Continue reading

Touch sensor programming by yr 3 and 4 with Arduino

I love touch sensors. Such an easy thing to teach in class and fun to act out with children.

Today we’ve been using a touch sensor with Scratch for Arduino. The sensor we use is the Adafruit Capacitative Touch sensortouch sensor

I like this because it’s visual (it lights up green) and is easy to program. Just hook a wire into an analog INPUT and watch the value drop.

What happens is the value is around 400 – 600 depending on the voltage. But when you touch the wire, it drops to 20 or so.

Continue reading

Coding music in a primary school with Arduino

A noisy lesson – take a couple of speakers and get them to play a frequency. The frequency range is about 30 hertz to 20,000 hertz. As you get older, the top level you can hear goes down. I like this lesson as it teaches some key words such as frequency, tone, pitch and vibration. It also builds up into teaching the idea of variables as well as functions. Plus it teaches music.

The basic code for Arduino:

tone (10,500);  // 10 is the speaker pin, 500 is the frequency.

Easy to pick up. Here’s an example.

It’s just tones at the moment. We can use this to make music as well.

Programming a light sensor alarm in a primary school

The basic principle of a light alarm is to measure any changes in the light levels. If the level goes above or below a certain level, something is triggered.

I like this because it teaches variables and responding to a change in that variable.

FOREVER measure the light level

IF the level changes, do something.

You can even use the > and < signs to extend it. The circuit is very simple – a light dependant resistor, 10k resistor , 3 wires and an Arduino. You can add more OUTPUTS or use Scratch on screen to do something.

This is an example of Scratch reacting – by 10 and 11 year olds.

Programming RGB LEDs in a primary school

RGB LEDs are great. They can produce a range of colours depending on the amount of power give to each LED bulb. Once you have access to the colour codes, you can produce 256 x 256 x 256 colours. Which is a lot of combinations.

We use Scratch For Arduino. This allows you to easily edit the analog power outputs. Put in a delay and a repeat and you’ve got a disco. As it’s Scratch based, it’s easy to do for primary children.

Robot arm controlled with an old computer keyboard

They’re hard to find nowadays. Except if you go to a skip. Or a school.  I had an old keyboard lying around so followed a tutorial to get it to work with an Arduino. It’s got 4 cables – Power, Ground, Data and IRQ. You can get adapters or just take the cables apart.

You need this library - it’s pskeyboard.h

I then got my robot arm – available online for about  £35owi-535-robotic-arm-edge_1

I just took the wires for the motors rather than using the control box.

Then I used the Adafruit MotorShield V2.3


Continue reading

Maths, music and programming

So I thought I’d write some real blog posts, Just a chat about programming and what I’ve found out.

I love music. Well, I say that – I can play the piano with my right hand as long as it’s not too complicated. But I like listening to it and coding it. So some research has opened up the whole new world of maths, music and frequencies. I love teaching it as I can cover maths and science – and get the key words in.


The physics.

speed of sound = wavelength * frequency

The frequency of A4 (the A after Middle C) is 440 Hz

The wavelength of A4 is 78.41 cm

78.41 * 440 = 34,000 cm / s (Speed of sound = 345 m/s)

As the notes go up, the ratio between the first note and the other notes is related to the (12th root of 2 ) raised to the power of the note number.

Continue reading