Go Down

Topic: three digit integer value into an array[3] (Read 498 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