Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Converting pot reading range from 1.0 to 0.0

  1. #1
    Junior Member
    Join Date
    Jan 2021

    Converting pot reading range from 1.0 to 0.0

    I've been googling for ages to find something that I thought would be straight forward.

    I want to convert the reading of a pot to a range from 1.0 to 0.0. To one decimal place that is. I keep finding ways to convert to 1 decimal place using Serial.print but that's not what I want, I want the actual variable to change to that.

    There has to be a simple way!

  2. #2
    Senior Member houtson's Avatar
    Join Date
    Aug 2015

    try something like:
    // if pot_raw_value is an int holding the value of the pot 0-1023
    float pot_value = floor(pot_raw_value/102.3f)/10.0f;

Posting Permissions

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