Go Down

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


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


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.


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!

via Egeo 16
Torino, 10131