Arduino Level Crossing Part 1

Recently, I purchased an Arduino Uno from Maplins (a UK electronic store). when I first got in, I simply experimented with LEDs. l then realised that I could make level crossing lights. The idea is that, when you press a button, a yellow light come on for a couple of seconds. Then, I have two red LEDs which come alternately. For example, when the left LED is turned on, the right LED is turned off.

In case you haven’t realised or simply don’t know, I live in the united Kingdom. The normal operating sequence of a level crossing is that a yellow light and siren will come on for a couple of seconds. After that, both the siren and the yellow lights switch off. The two red lights will start flashing alternately whilst barriers lower to block the road. Once they are down, the red lights lights continue to flash. Once the train has one past, the barriers raise and the red lights stop flashing.

The wiring for the lights was fairly straight forward, I simply wired each LED to a 220 ohm resistor (to to protect my Arduino board) I connected each end of the LED (which was not connected to a resistor) to Ground. The end with a resistor was connected to a digital pin on my Arduino. I connected the LEDs to pins 4, 5 and 11. Below is a picture of what the circuit looks like on the breadboard.

Level Crossing Lights rev 1

As you can see, I have wired all of my ground connections to the ground rail on my breadboard. I then wired the ground rail to my Arduino ground pin. I did this to not only save Arduino pins but also to make the circuit easy to modify in the future.

In terms of writing the code, I basically used a sketch build into the Arduino IDE called ‘blink’.  I added extra lines of code and changed the delays.

Here is a youtube video of it in operation. Please note, the lights currently flash continuously until either power is removed from the board or the reset button is pressed.

The next step was to hook up a button. I followed the tutorial on the Arduino.cc website. However, I did not have the correct resistor. The tutorial said that I need a 10K ohm resistor. However, I had to use a 1K ohm resistor as this was the closest to the required resistor that I had. After quite a bit of trial and error, I managed to get the circuit to work. I then implemented the button into my level crossing lights code. Again, I used parts of the button example code, which is built into the Arduino IDE, in my level crossing code. So far I have set it up so that when you hold down the button the red lights start flashing alternately. I have defined a ‘method’ in my Arduino sketch that switches the left LED on for a short amount of time. It then switches off and then the same happens to my right LED.

I am still working on getting the button to work. I will do another blog post so watch this space.

 

My first song (tune)

Recently, I started using Garageband on my newly purchased Macbook Pro. I made this song (it is more like a tune as there are no lyrics!) which I though I would share with the world. I have uploaded it to Soundcloud.I  have called it ‘Confusion’ because the genre is mixed up slightly.

Please feel to share and please follow my channel on Soundcloud. However, it is for non-commercial use only!

I’m Back!

As you have probably noticed, I have not been active on my blog recently. However, I am now back! I will be doing live streams on Twitch and Youtube videos mainly on Minecraft.

Very recently, I purchased an Arduino Uno. I will be doing posts on what I do with it.

With regards to pi-guide.co.uk (my other blog), I will be adding tutorials on how to use the GPIO pins and other features of the Raspberry Pi.

Lightwater valley review

On saturday I went to Lightwater Valley theme park which is in yorkshire.

Lightwater valley is the home of europes longest roller coaster, the Ultimate. The ride is 1.5 miles long! I wnt on the ride once. When you first leave the station you go around the corner and up the first lift hill. When you reach the top there is a big drop! There are then a few tight turns and you are half way there. You go up a second lift hill but this time you drop into the woods. There are lots and lots of tight. The second half is a lot more violent than the first half.

Then we went on twister. This is a ride where your carrige turns as you go around the ride. This was my favourite ride. The ride remindes me of the game Mouse Trap. Once you are at the top of the ride you go around some twists and turns. Your carridge turns a little bit but not that much but it is still scary as you turn violently. The ride then features to drops one which you get your picture taken on. The next level is very similar to the previous but this time you are constantly spinning. There is then a slight drop and you go over this wave type of track and then you are back at the station. Overall twister is brilliant. If you like rides which are thrill rides but aren’t too big, this ride is for you. I went on this ride 3 times!!!

The next ride I went on was Raptor Attack. This is an underground ride. First, you wait in a queue above ground. Only a group of people at a time are taken underground presumably for health and safety reasons. You then wait in a short queue and board your carridge. The ride is quite fast. The best way to describe it is the drop is no bigger than the drop on twister. The ride is always turning except for the lift hill and the drop.

When we were there there was a little bit of a wait. Im not certain why but apparently the ride broke down before we boarded the ride. The people on the ride were evacuated.

There are lots of other rides you can go on at Lightwater valley which I didnt go on incliding a pirate ship that goes upside down.

Overall Lightwater Valley is a fabulous theme park. There is free parking and, on the parks doorstep, a shoppng village. It is very wel looked after an the staff seem nice. It is DEFINIGHTLY worth a visit!!!!

Preston FM

Last time I went to a  Raspberry Jam, I was interviewed by a dj from Preston FM. Part of the interview is on Preston FM between 11 and noon today.

To listen go on their website or tune in using theFM frequency 103.2.

I will put a copy of the interview here during next week.

New website!!!

Today, I have launched my second website raspberrypi-guide.co.uk . It is a site which will guide you on using your Raspberry Pi. It was only launched today so has little information at the moment.

THIS SITE WILL BE REPLACING MY RASPBERRY PI PAGE!!!

I am still going to update this site regularly.  Please use the hashtag #RPiGuide to help spread the word!

Preston Raspberry Jam

Last night, I attend the Preston Raspberry Jam.  It is an event for Raspberry Pi enthusiasts.  Last night was different. Some people, including me,  had a demonstration of what they had done using there Raspberry Pi.  Everyone went round in groups of three to look at the demonstrations.

I was demonstrating my timelapse I made recently. I will put a video on youtube to tell you how I did it. I was also demonstrating how to remotly control your Raspberry Pi however I could not connect to the internet easily and I could not use port 22. I got asked lots of interesting questions and it was great fun.

There was also refreshments which were all fabulous. I also won an ultrasonic sensor to use with my Raspberry Pi. I will be posting videos onto Youtube about projects I will be doing using it. One idea I have is to make it detect a person when they walk into my room. Their picture will be taken. I will press ctrl c when I walk in to disarm the system.

Overall, I had a fantastic evening and , you did it again Alan, you created another fantastic Raspberry Jam.