Go Down

### Topic: Colour of lights depending on speed (Read 1 time)previous topic - next topic

#### PaulRB

#15
##### Dec 29, 2017, 12:49 am
No, you cannot measure speed with an accelerometer. But you can measure rate of change of speed, tightness of turns, that kind of thing. If you want a light display that changes as you manoeuvre on the board, I think it would work well.

#### orin635

#16
##### Dec 29, 2017, 12:53 am
Sounds interesting. But I have no clue how I would do that. Could you explain how?

#### PaulRB

#17
##### Dec 29, 2017, 01:00 amLast Edit: Dec 29, 2017, 01:13 am by PaulRB
You would attach an accelerometer module to the Nano. Some connect using 3 analog inputs. Some connect via i2c bus. The code would read the acceleration in X, Y & Z directions and use some formula to turn this into colour and brightness for the led strips. You can try lots of different formulae until you find one that gives effects you like.

X direction would be along the board. So when you push off, you get a big positive reading. When you brake or slow, you get a negative reading for X. When you move at a steady speed, you get a zero reading.

Y direction would be across the board. When you turn left, you would get a positive reading. The harder the turn, the higher the reading. When you turn right, you get a negative reading. When you go straight, you get a zero reading for Y.

Z direction would be up (positive) or down (negative).

Keep things simple at first, maybe just read X and use that to begin with.

Here is an example board. As you can see, it has 3 outputs which you would connect to 3 analog inputs on the Nano.

#### orin635

#18
##### Dec 29, 2017, 01:18 am
That's sounds alot cooler of an idea which id love to do.  I just would have no clue how to code that I'm only starting the learn now.

#### PaulRB

#19
##### Dec 29, 2017, 01:38 am
Ok, I think this would be a good project for a beginner to practice coding. We can help you learn.

I think you should get a Nano, an accelerometer module (adxl335), a small breadboard, a single rgb led, some led series resistors (e.g. 330R) and some connecting wire and build your circuit.

#### orin635

#20
##### Dec 29, 2017, 01:56 am
Well id prefer to not uses a breadboard and more leds and thank you very much I can't wait to do this project

#### artisticforge

#21
##### Dec 29, 2017, 02:37 am
I just used them in a simple infinity mirror and have the switch to toggle between with lights I want. with an accelerometer will I still be able to get for example 0-10km/h = Green lights etc...
The simple answer is No. You need to program and provide the calculations for what you want to do.
With the hall-effect switch, you have to count the rotations of a wheel. knowing the diameter of the wheel
you define the wheel circumference. passed on the wheel circumference you calculate how many rotations does it take for 1 kilometer.

While you are counting wheel rotations you need to count how fast the rotational count is occurring.
The wheel rotations per unit time will give you a rough Kilometer per hour.
Once you have that you drop it into a switch statement to determine what color the LED strip should be.

You will need to make the rotational count and rotational rate interrupt driven if you do not want to miss any data.

Either way you have some programming and calculations to work through.
This is not a plug and play project.

How you mount the hall-effect sensor so that it is not destroyed in a skateboard accident?
Where to mount the power mosfets?
This is not a weekend project, this is a long project.

building the power mosfet controller for the analog LED strip should alone keep you busy.

><>

Go Up