Skip to main content
Associate III
Jul 30, 2024 9:32 AM UTC
Question

How to convert array to int

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.

7 replies

Andrew Neil
Super User
Jul 30, 2024 9:46 AM UTC

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

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate III
Jul 30, 2024 10:07 AM UTC

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?

TDK
Jul 30, 2024 10:55 AM UTC

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."