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

    Join Date
    Feb 2012
    Posts
    116
    Helped
    0 / 0
    Points
    1,859
    Level
    10

    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.

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 256,166, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    44,672
    Helped
    13589 / 13589
    Points
    256,166
    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.



    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 3
    Points: 6,058, Level: 18

    Join Date
    Feb 2015
    Posts
    992
    Helped
    284 / 284
    Points
    6,058
    Level
    18

    Re: Variable conversion uint16_t to int




--[[ ]]--