Amil Mohanan’s Blog

*batteries not included 
Filed under

arduino

 

Arduino Bike Computer

         
Click here to download:
Arduino_Bike_Computer.zip (2852 KB)

I’ve been really getting into cycling again the last few weeks, I changed the tyres on my mountain bike and I wanted to see if it had made a difference to my speed. The easy thing to do would have been to go and buy a bike computer, but where’s the fun in that? Instead, I opted for a magnet attached to the front wheel to trigger a reed switch mounted opposite on the fork (although a hall-effect sensor would have worked just as well) to control an Arduino connected to an LCD screen.

The principle is simple, the magnet was cable-tied to the reflector on the front wheel, which was 9.5 inches from the axle, and every revolution at that point meant that the bike had travelled 59.69 inches. This was used to calculate the miles per hour and total distance travelled.

There are quite a lot of wires for the LCD, which makes it hard for me to write up, but this tutorial from ladyada good for reference. One of the trickiest parts was working with floating point numbers and sending them to the LCD screen, I resorted to using this bit of code from mem.

I wired it all up and stuck it inside a cardboard box that I had cable tied to the handlebars, which got some funny looks from people when I rode past, but it got the job done! The Arduino was powered from a battery clip with four AA batteries. There are still some minor issues with the code and it’s still a work in progress, but it worked fine when I rode it along side a car and read out the readings. The source code is attached.

Click here to download:
MPH_Calcuator.pde (3 KB)

Filed under  //   arduino  

Comments [2]

Audio Visualiser using Processing and an Arduino

This was the first project I made using my Arduino, I wanted to make something that created different colours using LEDs. This was the end result.

The setup is really simple, you need:

  1. 1x Arduino 
  2. 1 RGB LED or 1 each of Red, Green and Blue 
  3. 3x Resistors for the LEDs
  4. A microphone maybe required (it depends on the sound card)
  5. Wires 

The RGB Full Colour LED I’ve used came from Maplins. The Ghost head I used in the picture came from an Ikea Night Light that I took apart, its made from a white rubbery material which made it ideal for diffusing the light, also makes it look cute!

     
Click here to download:
Audio_Visualiser_using_Process.zip (620 KB)

Wire up the breadboard as shown in the picture, the Full colour LED shown in the picture could be substituted for three different coloured (Red, Green and Blue) LEDs as well. Connect the Arduino using the USB port to the computer and open Arduino_ColourVisualiser.pde in Arduino (make sure it is opened from the Arduino program rather than Processing) from the source code and compile and upload to the Arduino. Then, open Processing_ColourVisualiser.pde from the Processing Program and press Run. You may need to change the Serial port in line 54 in processing if your system uses a different port for the serial connection.

The LEDs are controlled by the Arduino, which receives the values for the PWM digital pins via serial from a program running in Processing. It’s important that the LEDs are connected to the PWM (Pulse Width Modulation) pins (11, 10 and 9 on the Duemilanove) from the Arduino in order to be able to vary the dimness using digital output.

The Processing program generates three random numbers between 0 and 255 using the beat detection from the Minim library and the Line In from the computer. It listens for Kick, Snare and Hat frequencies from the input, the numbers are then sent via serial using the USB connection. The Arduino program read the three numbers and uses them to set the pulse on the pins that power the three LEDs. If it worked properly, it should light up in different colours reacting to background noise (such as talking if there is a microphone attached) and any music that is being played on your computer.

Click here to download:
ColourVisualiser_SourceCode.zip (2 KB)

Filed under  //   arduino  

Comments [2]