Skip to main content
Associate III
July 30, 2024
Question

How to convert array to int

  • July 30, 2024
  • 2 replies
  • 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?

2 replies

Andrew Neil
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

 

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
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?

TDK
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.

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

It’s kind of like decoding hi in morse code once you know the steps, it all clicks instantly!