Skip to main content
Visitor II
July 30, 2024
Question

How to convert array to int

  • July 30, 2024
  • 1 reply
  • 1580 views

halo!

i have a adc_value as array and i hava this for potentiometer, i want to call the adc_value as int, but i can't thingking for this now, can anyone help me?

    This topic has been closed for replies.

    1 reply

    Super User
    July 30, 2024

    Your question doesn't make sense - please clarify.


    @meriarajagukguk wrote:

    halo!

    i have a adc_value as array and i hava this for potentiometer


    So what does this "array" represent - a sequence of samples of the potentiometer values?

    What type is the array?

     


    @meriarajagukguk wrote:

    i want to call the adc_value as int, 


    What do you mean by that?

    Surely, each element in the array can be accessed in the normal way? Cast it to an int if it isn't already an int.

     

    https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

     

    Visitor II
    July 30, 2024

    I have an ADC value that I store in uint32_t BUFFER_DAC[4];
    and I want to use that value in 'int input' but I don't know how to convert/call it to be int.
    Can anyone help me?

    Super User
    July 30, 2024

    Conversion from uint32_t to int is automatic. Shouldn't require anything more than using the variable name.

    int x = BUFFER_DAC[0];

    Buffer should probably be uint16_t, not uint32_t.