Go Down

Topic: three digit integer value into an array[3] (Read 522 times) previous topic - next topic

RobMan28

Hey! I am new to programming the Arduino and would like to convert a three digit integer value into an array[3]

observe the following code:

 potVal = analogRead(potPin);
 potVal = map(potVal, 0, 1023, 100, 200);

lets say
potVal = 123;

how would I make array[] = {1, 2, 3};

??

Thanks in advance


TeamMCS

The modulas function should be able to help you. (Math.mod in the Math.h library)

You could also use a bitwise shift but that's probably not required in this instance.

Mitch_CA

Why do you want each digit in a separate array element?  It seems like an odd request and I wonder if there isn't already an easier way to do what you want.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy