Results 1 to 2 of 2

Thread: Maping a value in python

  1. #1
    Join Date
    Dec 2008
    Rep Power

    Maping a value in python

    I was wondering if there was a way to map values in python. When programing the arduino there is a way to take a value and convert it into a smaller or larger value. This function for arduino is called map. After searching the web I discovered that the map function in python is used differently. Here is what an arduino map function would look like "map(val, 0, 180, 0, 90)". This would take the integer "val" which will be between 0 and 180 and convert it to a number between 0 and 90. I could not find the mathematical formula that the arduino uses to do this so my question is how can I do this in python either mathematically or using a function?
    Dalton Caughell

  2. #2
    Join Date
    May 2008
    Rep Power

    Re: Maping a value in python

    From the map function documentation on :

    For the mathematically inclined, here's the whole function
    long map(long x, long in_min, long in_max, long out_min, long out_max)
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    "If A is a success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."

    Don't be a HelpVampire

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Discussion Python Project Sharing and help Thread
    By ROBOTMAN in forum Software and Programming
    Replies: 239
    Last Post: 12-04-2009, 08:08 AM
  2. Question(s) Best robotics Language?
    By trevben1 in forum Software and Programming
    Replies: 37
    Last Post: 11-15-2009, 12:34 PM
  3. Question(s) Whats wrong with my python code?
    By ROBOTMAN in forum Software and Programming
    Replies: 8
    Last Post: 02-21-2009, 08:30 PM
  4. MS Robotics Studio
    By asbrandsson in forum Software and Programming
    Replies: 39
    Last Post: 01-11-2009, 08:14 AM
  5. Discussion Programming Languages for Robotics
    By LinuxGuy in forum Software and Programming
    Replies: 27
    Last Post: 05-25-2008, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts