Pages: [1]   Go Down
Author Topic: three digit integer value into an array[3]  (Read 480 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

The Big Smoke
Offline Offline
Sr. Member
****
Karma: 0
Posts: 260
Hacking and Slashing
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Waterloo, Canada
Offline Offline
Full Member
***
Karma: 1
Posts: 242
Engineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: