+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Full Member level 1
    Points: 1,828, Level: 9
    Achievements:
    7 years registered

    Join Date
    Feb 2012
    Posts
    114
    Helped
    0 / 0
    Points
    1,828
    Level
    9

    Variable conversion uint16_t to int

    Hello,

    I wish to convert my ADC data (uint16_t, 10bit data) to "int" so I can perform mathematical operations. Basically my goal is to make my version of "map" function in Arduino IDE, ex. int Value = map(ADC, 0, 1024, 0, 255);

    So how can I convert uint16_t to int? Thank you in advance.

    •   AltAdvertisment

        
       

  2. #2
    Super Moderator
    Points: 252,684, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    44,014
    Helped
    13388 / 13388
    Points
    252,684
    Level
    100

    Re: Variable conversion uint16_t to int

    uint is converted to int automatically when making an assignment. This is a feature of the C language. Sized data types used in some libraries like uint16_t are just aliases of the generic C data types and should also undergo automatic conversion.



    •   AltAdvertisment

        
       

  3. #3
    Advanced Member level 3
    Points: 5,819, Level: 18

    Join Date
    Feb 2015
    Posts
    957
    Helped
    273 / 273
    Points
    5,819
    Level
    18

    Re: Variable conversion uint16_t to int




--[[ ]]--