Archive | Crumble Projects

Programming challenge: a temperature-sensitive light.

This project builds on the previous post, where we explained how to set Sparkle colours using the “RGB” block:

Sparkle RGB block

It was inspired by the type of night-lights that are available for babies’ bedrooms, where the colour of the light indicates to parents if the room is getting too hot or too cold.

We want the Sparkles to display predominantly “cool” colours if the room is too cold and “warm” colours if it is too hot. As we are using the matrix display, it would also be nice to have a pretty “twinkling” effect.

The block which randomly changes the colour of each Sparkle in the matrix display

The program is, therefore, based around the block, above. The colour of each Sparkle in the array is updated, randomly. The level of green light also changes, randomly. If the value of “red” is low and the value of “blue” is high, the Sparkle colour will vary between blue and cyan (depending on how bright the green light is) while if “blue” is low and “red” is high, it will vary between red, orange and yellow.

A previous night-light project shows how to connect up the Crumble, battery pack and Sparkle matrix display. The input from a light-dependent resistor (LDR) was used to control whether the lights are on or off. In this project, instead of the LDR, we are using a thermistor (a resistor whose resistance varies depending on temperature). You can simply attach a croc clip to each “leg” of the component but, to make it a bit easier to handle, we have soldered ours onto a “crumbliser”

The first thing we need to do is calibrate the input, i.e. work out what temperature the resistance of the thermistor corresponds to. The thermistor is connected to “A” and “B” on the Crumble: “A” will be the output and “B” will be the input. The following program allows us to monitor the value of “B”. As it depends on temperature, we have assigned it to a variable called “t”.

Something I learnt during the course of this project is that, if you want to calibrate an analogue input, it is better to connect it across 2 of the Crumble I/O pads (A,B,C & D) as we have done, here, rather than connecting one pad to the Crumble and the other directly to the “+” pad on the battery box. This is because the voltage level from the battery box can vary, whereas the Crumble itself outputs a fixed voltage.

We then immersed the thermistor in hot water; in iced water; put it outside; and, finally, my 6-year-old held it in his hand. We watched how the value of “t” changed (in the “Variables” menu of the Crumble software) and my 9-year-old made a table and then a graph of the results.

Based on this investigation, we decided that the red emitter should be off (0) when t = 85 and fully on (255) when t = 170. (Ice water and boiling water being a bit too extreme in this case!) The blue emitter can then simply be the inverse of this (i.e. 255 minus the value “red”).

Our table of results and graph

I briefly explained the formula for a straight-line graph (y = mx + c) and “we” determined that m = 3 and c = -250. We then input these numbers into the Crumble program in order to convert the value of the input “t” into our outputs “red” and “blue”:

We also used two “if” blocks to set limiting conditions to prevent the value of “red” (and, hence, “blue”) going higher than 255 or lower than zero.

The completed program is:

Crumble program for our temperature-controlled night-light

The program is inside a “do forever” loop so the colour of one random Sparkle in the array is changed every 100 ms.

It is difficult to capture the different colours on camera, but here is the finished night-light (mounted in the Sparkle matrix pixelator) at three different temperatures:

Aaah…. just right!

Science with the Crumble: Colour mixing

Red, Green & Blue:

Can you make your Sparkle baton display a rainbow? The simplest way is to set each Sparkle colour, in turn, with the computer’s colour picker:

Simple “sparkle baton rainbow” program
Sparkle baton displaying a “rainbow”

But do you know how a Sparkle LED can display all these colours? The primary colours of light are red, green and blue (RGB). Each Sparkle has a red, green and blue LED inside and the relative brightness of each of these determines the colours that your eyes see. Mixing equal amounts of red and green gives yellow; green and blue make cyan; and blue and red make magenta. Red, blue and green mix together to make white light.

Under the “Sparkles” menu in the Crumble software is a block which allows you to set the level of each RGB emitter (0 is off; 255 is maximum brightness). The following program will, therefore, display the primary and secondary (yellow, cyan and magenta) colours along the baton.

Primary & secondary colours

If you are interested in seeing how other colours are made, the colour picker will tell you the RGB values of the current colour and allow you to change them, via sliders or by typing the value. Here, for example, we have chosen orange:

The red emitter is fully on (255), green is at half-brightness (127) and blue is off. If we now increase the blue to fully on, we get pink:

Note: this is the MacOS colour picker, Windows may look different but should still have the same information. You might also notice a Hexadecimal colour code (Hex code #FF7F00): I won’t go into more detail, here, but if you are interested in computer programming and/or graphic design you should investigate this further. 

Colour & the Human Eye:

We can use the block

to show that equal amounts of red, green and blue light mix together to make white light. The program, below, though, also demonstrates our eyes’ persistence of vision.

Sparkle cycling between red, green & blue

The last Sparkle on the baton (“sparkle 7”) cycles round the primary colours more and more quickly. The time interval starts at y=1000ms then halves after every z cycles while the number of cycles starts at z=1 and then doubles. As the LEDs cycle faster our eyes will first perceive a flickering and then a steady white light. You can show, though, that the LEDs are still cycling, even when the white light appears steady, by rapidly moving the baton from side to side: now our persistence of vision lets us see separate red, green, and blue “lines”.

Further Colour-mixing Activities:

Can you use your colour mixing knowledge recreate the “rainbow” display, above, but now get it to scroll along the sparkle baton? This diagram may help:

RGB colour mixing diagram

If you have a sparkle matrix, you can experiment with more colour effects. For example, what do you think the following program does?

Or pick your favourite colour(s) to draw a picture:

Sparkle matrix displaying a pink heart.
Happy Valentines Day!

The next blog post will explore using variables as RGB values and show how to use an input to control the Sparkle colours.

More Christmas Crumbling

As we draw closer to Christmas, we thought that it would be nice to share a few festive ideas. If you end up at a loose end over the holidays, especially if you have kids, then why not give these seasonal makes a go? They’re a great use of any cardboard that won’t fit into your recycling bin!

First up, we have our uber-christmassy Crumble-powered Rudolph, complete with flashing red nose. A quick internet search brought up loads of different cardboard reindeer templates. After cutting out all of the pieces, we got to work on the nose. For this, we used a ping pong ball. We sliced part of it off, and then glued it to the nose. We wired up a Sparkle, and wedged it inside the nose.

We then secured the rest of our reindeer together, and wired up the Crumble. We stuck the components towards the back of the head which allowed it to stand up on a table.

There we have it, one quick Rudolph, ready to guide your sleigh.

🎶Rudolph the red-nosed reindeer, had a very shiny nose, and if you ever saw it, you would even say it glows.🎶

Next up, we have another festive-favourite. If you, like the vast majority of people over Christmas, don’t need more cakes in the house, then why not have a go at a gingerbread-free faux gingerbread house? There is a wealth of inspiration to be had, just by doing a quick image search on the internet. Once your house is made and decorated, then we covered the windows with some tracing/baking paper, to diffuse the Sparkles inside. We then wired up our Crumble with a Sparkle baton, because you can never have too many lights – especially at Christmas!

Once it’s all wired up, simply program your required lighting sequence – we went for a flickering fire-like program (as seen here). Pop it inside the faux gingerbread house, and you’re all set!

If you have been inspired by any of these projects, or want to share something else awesome with us, then give us a shout on the forum or Twitter.

Add some Magic into your next Project – Magic Candle

The leaves are turning, conkers are coating the path and the ground seems to be permanently wet. This can only mean one thing – it’s Autumn. This means that it is nearing Halloween, and Harry Potter can be found on the tv most weekends. Who doesn’t love a bit of magic, right?

We wouldn’t declare ourselves the biggest of Harry Potter fans, but, one of the team has decorated his downstairs bathroom with all things Potter… Anyhow, we thought it would be a perfect opportunity to perform a bit of magic with the Crumble!

You could do much more than a candle, we’d love to see some of your magic creations!

We have made a ‘Magic Candle’. Spoiler Alert: we have used a reed switch and a magnet to control the Sparkle!

As you can see from the photo, we’ve made our candle using a rolled up piece of white card. We’ve used a glue gun to add some ‘dripping wax’ too. Inside the top we’ve placed a Sparkle, and a reed switch. We then placed a piece of plastic over the Sparkle (we cut up a scrap of frosted polypropylene) and put it through the ‘top’ of the candle. We’ve used our laser cut wand (with a magnet in the end).

After making the candle, it’s really easy to program and control… ahem, I mean cast a spell, to light it up.

The program (code) for this is simple, once you get your head around it. The reed switch (as the name suggests) is a type of switch. This means that when a magnet is placed near it, it closes, and the current flows through to the Crumble. When the magnet is moved away, it opens and the current stops.

Our code waits for the wand to be waved, which will set A HI, then it runs a ‘flickering’ Sparkle algorithm. We set the Sparkle to random shades of Red, Orange and Yellow, and wait a few random milliseconds before changing it again.

Note: the wait 100ms allows you time to move the wand away from the switch again.

When the wand is waved again, it sets A Hi, waits again and turns the Sparkle off. Simple!

And there you have it! One ‘Magic Candle’ ready to mystify and amaze.

We would love to take credit for the magnet and wand idea to set off a reed switch, but that comes courtesy of Mike and Beckie at UKSTEM. (We are definitely bigger Harry Potter fans than they are, though!)

A Crumble-Powered Automatic RGB Nightlight

Sometimes inspiration can be hard to come by. We have known for a while that we’ve wanted to make a nightlight, but didn’t know how to make it different from all the rest.

We stumbled across an interesting video on YouTube which peaked our interest and gave us the inspiration we needed. How awesome would this nightlight look if we added a whole heap of Sparkles (a Matrix display) and gave it a Crumble kick?!

The Crumble-powered RGB nightlight was born.

Although this post will be a whistle-stop tour of the process, when we have our finished Sparkle Matrix display, we will definitely work on some in-depth instructions and teaching resources.

We started off by preparing a cardboard box, by removing all of the sellotape. We then glued it back together, to make sure that it was sturdy.

We then cut the faces of the box off, leaving a border. This would give us the frame for our light.

After this, we drew some straight lines on a word document and printed off 5 copies. We then trimmed each sheet so that it could be glued inside the 5 faces of the frame.

When we had finished our light, we decided that we didn’t like the bare cardboard, so we used a silver permanent marker to give it a metallic look.

Wiring up the Crumble was simple enough.  After connecting the Sparkles (inside the shade), we connected a light-dependent resistor (LDR). One end connected to a + output, in this case from the batteries, and the other end connects to an input (A, B, C or D). We used A.

It’s really easy to use an LDR with the Crumble. Take a look at the following program. When the analogue value of the LDR (we’ve renamed it to be helpful) is above 90, turn all of the Sparkles off,  if it isn’t above 90, and therefore less than it,  then turn the Sparkles on.

To get the nice RGB effect, we have cycled through the red, green and blue values.  This graph shows how increasing or decreasing the different values gives us different colours. Doing it in this particular order gives us a lovely rainbow effect!

We have created variables called Red, Green and Blue. We then set the corresponding red, green and blue Sparkle values to our variables. We have cycled up/down the RGB values to give us our transition of colours. Each time the colour changes, we check to see the value of the LDR, and whether or not to turn the lights on/off.

And here is our RGB nightlight, in all of its glory! When the Sparkle Matrix gets finalised, we will create some more in-depth teaching resources for this project, as it’s easy to make and really satisfying.

Getting Musical with the Crumble

A Crumble powered instrument that can play a tune? You must be mad!

Don’t worry, we thought we were too, but after having this idea in our head for a long time, we finally bought a glockenspiel to try it out-  and lo and behold our Crumble powered glockenspiel is alive.

Surprisingly, you don’t need many parts to make the instrument work. A glockenspiel with a beater, two servos, some cable ties and a sticky pad or two. We placed it on a spare piece of corriflute so that we could keep the servos and the glockenspiel aligned.

We needed two servos for this. One servo with the “cross” attachment, and the other with the “double arm”. These were then wired into the Crumble, one on A and the other on B.

The two servos were then connected with sticky pads and cable ties. The bottom servo moves along the X axis (left to right), and the top servo along the Y axis (up and down).

To allow us to easily play the given notes, we created a variable for each one and worked out, through trial and error, which notes were at which angle.

We then moved onto setting out variables for a crotchet, a minim, and then the angles at which the top servo needs to be to hit the glockenspiel, and where it should rest at.

This is the block of code to hit the ‘F’ key, for one crotchet (same as the beat). The total of the wait statements is 750 milliseconds, which equals 80bpm.

And there you have it, one Crumble-powered Glockenspiel! Our instrument came with some free music, so we decided to use one of those pieces. After piecing together many snippets of code, here is Beethoven’s 9th Symphony – well the first line, in all of its Crumble-y glory.

Christmas has arrived!

Our first proper Christmas since we moved in to our new building with Mindsets. We’ve decided to mark the occasion with a suitably decorated tree!

We connected 20 Sparkles and a Sparkle Baton together using croc-leads. We then wrapped these around the tree, with the Baton on the top. The croc-leads are almost a decoration in themselves!

The Crumble is connected to a Raspberry Pi, which is connected to our network, meaning we can remote-desktop in and change the lights! It’s pretty much an Internet of Things Christmas tree.

We decided to add our big red button near the base of the tree, to allow the user to cycle through the light sequences. The code runs a light sequence, and waits for the button to be pressed before moving onto the next sequence.

We decided that the tree was a bit bland, especially during the day time, so we added a few more decorations to it.

And there we have it, our IoT Christmas tree, ready to be programmed by anyone in the office.

Science with the Crumble: Test your reactions

HYPOTHESIS: Humans react more quickly to something they hear compared to something they see.

In order to test this hypothesis, we used:

  • Laptop with Crumble software installed
  • Crumble controller & Sparkle baton
  • Crumble-friendly battery box; 3 AA batteries
  • Croc-leads and a micro-USB cable
  • “Crumble-friendly” switch and buzzer

The Crumble, Sparkle baton, switch and battery box are connected in the same way as the last reaction timer project (although the switch is connected to input A, rather than B). The program, however, is much simpler:

At the start, all the Sparkles are turned off. The Crumble waits for a random period of time (between 2 and 6 seconds) and then begins lighting the Sparkles in quick succession (every 50 milliseconds). The aim of the game is to press the switch as quickly as possible. Note: you have to hold down the switch until you have read your “score”. When the switch is released, the game restarts. Joseph & I discovered that, after a bit of practice, we could consistently press the switch after 4 or 5 Sparkle LEDs had lit up (i.e. after 150-200 milliseconds). 

In order to test whether we could react more quickly to a sound, a buzzer was then connected between “output B” and “Ground” (a “-” pad on either the battery box, or the right-hand side of the Sparkle baton). The program was modified so that the buzzer turns on at the same time as the first Sparkle LED:

For a fair test, you have to close your eyes while playing – but remember to open them and read your score before releasing the switch! Now we found that we could press the switch after 3 LEDs were lit (100 ms). 

So, our small sample does support the hypothesis, above. Further reading suggests that humans react even faster to touch-stimulus: can you think of a way to measure that with the Crumble? If you do the experiment with a larger group, let us know your results and we will publish them, here!

Programming challenge: Traffic lights

IMG_1538We used:

  • 1 laptop with Crumble software installed
  • Crumble controller & Sparkle baton
  • Crumble-friendly switch & ultrasonic distance measuring sensor
  • 1 Crumble-friendly battery box; 3 AA batteries
  • Croc-leads and a micro-USB cable

The traffic light sequence can be programmed to run on a single Sparkle (change all the Sparkle commands in the program below to read “set sparkle 0 to..”), but using 3 chained together or, as here, a sparkle baton is more “true to life”. The traffic lights are set to be the last 3 sparkles on the baton (index numbers 5, 6, and 7 being green, amber, and red, respectively). The program is shown below:

traffic_lights

The sequence simply repeats every 3 seconds, but we can add a switch (here connected between the +ve battery terminal and Input A) to trigger the sequence. In the program below, the green light stays on until the button is pressed. 

button_cross

The program was then modified further so that the sparkle at the other end of the baton (index number 0) functions as a “pedestrian crossing”. When the “traffic lights” are green the pedestrian crossing is red. When the button is pressed the traffic lights cycle through amber to red and then the pedestrian crossing sparkle changes to green. After 5 seconds the pedestrian crossing sparkle changes back to red and the traffic lights continue through red-amber to green.pedestrian_cross

For the final challenge we also added an ultrasonic distance sensor with its “trigger” (T) connected to input “C” on the Crumble and “echo” (E) connected to “B”.

As in the program above, the button triggers the traffic lights to change to red. The “pedestrian light” (i.e. Sparkle 0) then remains green until the ultrasonic distance sensor detects a “car” approaching (in this case represented by a hand waving less than 4cm away). The “car” triggers the pedestrian crossing to turn red and the traffic lights to change to green.

Screen Shot traffic_ultra

Unfortunately, the resulting tangle of wires is not very attractive. (Note: I have used the “power out” pads on the Sparkle baton as power inputs for the ultrasonic distance sensor.)

Next challenge: construct something to hold the baton vertical and the ultrasonic module in the right position to detect a lego car!

FullSizeRender-3

Crafty Crumble Creations: A steerable buggy

FullSizeRenderWe used:

  • 1 laptop with Crumble software installed
  • 1 Crumble controller & 2 Crumble-friendly switches
  • 1 Crumble-friendly battery box; 3 AA batteries
  • A pair of motors (with croc-leads attached) & wheels
  • 4 long & 2 short croc-leads and a micro-USB cable
  • 2 K’nex wheels and an axle.
  • An egg box

The construction of the buggy is ridiculously simple: we pushed the axles of the motors through the sides of an egg box lid, as close to one end as possible, then attached the wheels. For the front wheels we pushed a K’nex axle through he other end of the box and attached a pair of similar sized wheels. (Lego technic would also work fine.) The Crumble and battery box then sit inside the buggy.

IMG_0894

FullSizeRender-3

The motors are connected to the Crumble’s motor outputs (the bottom two pads on either side of the Crumble). Note that to get the wheels to turn in the same direction and move the buggy forwards, the motors actually need to turn in opposite directions (as they are arranged back-to-back). This can be achieved in software, by setting one to “forwards” and one to “reverse” or, as shown here, by connecting one motor in the conventional way (red wire to the positive pad; black wire to the negative) and the other motor reversed (red wire to the negative pad).

One of the switches was connected between the second positive output of the battery pack and “input A” on the Crumble (the yellow croc leads). The other switch was connected between the Crumble’s “power out” (top right) pad and input D (the green croc leads). The battery pack is connected to the Crumble in the usual way.

IMG_0892

IMG_0893

The Crumble program is shown below. If both switches are pressed (“A is Hi” and “B is Hi”), both motors operate and the buggy moves forwards. If only one switch is pressed, only the motor on that side of the buggy runs and the buggy turns. The green and yellow croc leads are long enough that our 3yr-old can walk behind the buggy and use the buttons to steer it.

Screen Shot buggy prog

NOTE: The motor power is set to only 25%. This ensures that the buggy moves at a slow walking pace but it can also help to reduce glitches (e.g. the motor LEDs on the Crumble flicker, but the spindles don’t turn) due to interference being picked up by the long leads to the switches.