Let's Make Robots!

converting values. arduino #solved#

So here is the question in short.

Im using a arduino uno and have analog readings filtered to 0 to 50, i want to convert those values to 50 to 0 insted.

This is probably realy simple but my head is blank.

more detailed description is that i want to take the distance reading and make a speaker bep more frequently the closer the robot comes to something, brings back old videogame memmories.

A spekar is hooked up to digitalpin 3 and i have some code that beeps but i get stuck at making the beeps more frequent and  not longer... 

Big thanks to anyone who is willing to help!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

What you search might be this function:


map(value, fromLow, fromHigh, toLow, toHigh)


it's explained here : http://arduino.cc/en/Reference/Map



Thank you!

easier then i thought!


Thanks for the help!



OddBot ,You know the feeling you get when your looking for something but it was just to close to see...

The map function is great, with some trial and error it is now working as intended. Now i just have to itegreat it to the main code.