Lighthouse Project

lighthouse cover

Task: Create a program to simulate a lighthouse

Difficulty: Beginner/Intermediate

DSCF3752

For this project you will need:

  • One Crumble with USB lead;
  • A computer with the Crumble software installed;
  • One battery pack with batteries (not rechargeable);
  • One Sparkle;
  • One toggle switch or one light-dependent resistor;
  • Seven croc-leads.

For the lighthouse build you will need:

  • Card;
  • A clear plastic cup;
  • Tin foil;
  • Scissors/craft knife;
  • Glue/tape;
  • Coloured pens/pencils or paint.
Battery & Crumble

First of all, we need to connect up the battery pack to the Crumble (keep it turned off for now). We need to take care with this as we must make sure that the + on the battery pack goes into the + input of the Crumble, and – on the battery pack connects to the – one on the Crumble.

Battery & Crumble
IMG_20170823_100653

After we’ve connected up the battery pack, we need to connect one Sparkle, by using +, – and D. Make sure that the arrow on the Sparkle is pointing to the right (away from the Crumble).

IMG_20170823_100838

Now we need to connect either the toggle switch or LDR; both of which connect in an identical way. We need to connect one side of the switch/LDR to a + output (either from the battery pack, Sparkle or Crumble) and the other side of the switch/LDR to an I/O (A, B or C) input.

hint: if you connect to the + on the battery pack, it will make your Sparkle easier to manoeuvre. 

 

IMG_20170823_100838

Now we need to look at how to program our lighthouse. To begin with, we will get our Sparkle to flash in a pattern. It turns out that lighthouses have their own unique ‘light characteristics’ which mean that each one’s light pattern is unique. You can find out more here.

For this lighthouse, we are going to use the light characteristic of Southwold’s lighthouse. If you want to choose a different one, a quick internet search for the light characteristic of your chosen lighthouse  should do the trick.

 

simple flash

To get my Sparkle to be like Southwold’s, it needs to be on for 0.2s and then off for 9.8s. The code for this is nice and simple, we just need to remember to set the light sequence inside a ‘do forever’ loop so that it keeps repeating. We turn Sparkle(0) on, wait for 200ms or 0.2 seconds.

 

Now we are going to add in a toggle switch – this will allow us to control when the lighthouse is on. Before we start to program, It’s a good idea to double check that our switch is wired up correctly. One end should be connected to a + output e.g. from the battery, and the other should be connected to A, B or C; we will use A.

hint: you can use D as an input , but we need it for our Sparkle.

toggle flash

We now need to adapt our code so that when the switch is on (closed) and A becomes HI, the light will flash. We could do this in a number of different ways, but for this example we will use an ‘if _then’ block.

Every time the program loops, if the switch is closed, the Sparkle will flash but if the switch is open then nothing will happen.

toggle flash

If we want to take our project one step further, we can add in a light-dependant resistor (LDR). This will allow us to program our lighthouse so that when it gets dark, it automatically turns on.

To do this, we first need to swap over the toggle switch for the LDR. Then we just need to make a couple of minor adjustments to our code. An LDR works in such a way that the darker it is, the higher its resistance. If we monitor the input using ‘analogue(A)’, we will then be able to use an if statement to determine when to run the flash sequence.

ldr flash

In this code we have used a variable called ‘light level’, and every time the loop runs, ‘light level’ is set to the value of ‘analogue(A)’. This allows us to easily monitor the value of ‘analogue(A)’ and it will help us create the condition on which the Sparkle flashes. We found that using ‘If light level < 180’ worked well, so that the flash sequence started when the LDR was covered with a cupped hand.

Now that we have the inner-workings for our lighthouse, we need a lighthouse to put it in!

IMG_20170824_121603

First of all, we cut a 15cm x 22cm rectangle out of card. Then we applied glue along one of the shorter edges and rolled it up so that it became a cylinder. We clipped it with a paper clip for a few minutes to allow it to stick properly.

note: the paperclip was very big – it makes the cylinder look tiny!

 

IMG_20170824_121603

After that, we cut out a hexagon (on card) which was 10cm across, although it would work just as well with a 10cm x 10cm square. We then placed the Sparkle in the middle of it and marked where the input holes were. Then we carefully poked six holes where we had marked.

This then allows us to attach the Sparkle to the card using the croc-leads.

hint: make sure that the sparkle is in working order before the next step!

 

IMG_20170824_123543

Then we cut short slits into one end of the cylinder, which allowed us to stick the cardboard platform onto it, and two slits into the bottom of the cylinder to allow the croc-leads to ‘escape’.

We then glued the platform onto the tabs we had cut. This does mean that it’s very difficult to adjust the sparkle so if you don’t want to glue it, the weight of the Sparkle and the croc-leads should hold it together.

 

IMG_20170824_123543
IMG_20170824_124743

Next we took the plastic cup and cut it in two. We then lined the bottom of it, and half of one side with tin foil. This reflects and diffuses the light of the sparkle to make it more realistic.

After that, we drew a circle which was larger than the diameter of the base. We then cut out a small segment so that it looked a bit like Pacman! Then we glued one of the edges and taped it on the inside so that it became a cone, for the roof.

Next we taped the cone onto the bottom of the plastic cup, so that it came the top, and we placed this onto the platform.

 

IMG_20170825_104722_312

Finally, we added some colour. We used markers for ours, but you could easily use pencils, paint or even tissue paper and glue! If using paint or glue, it’s worth making sure you keep your Crumble and other components away from the mess so they don’t get damaged.