I'm drawing a blank on this. I used to do it in BASIC (many moons ago), but now I'm thrown off.
I just want to grab each of the digits individually from an analog read.
Can I do it mathematically, or do I have to convert to Char form?
I know it's simple, but I'm outputting data on a single 7-seg display.
The analogRead(A3) returns 16-bit data with upper 6-bit always zeros. That means that the actual data is 10-bit, and it can range from 000 to 3FF in hexadecimal number system (0 to 1023 in decimal number system). If you want to show them on 7-segment display devices at the same time, you need 3/4 display devices. If you have only one 7-segment display device, then you have to show the digits one after another with a time gap (say, 500 ms) among them.
You can use one or more of the following approaches to strip out the digits from the number (3FF/1023): 1. Use right shift method to extract hex digits. 2. Use %16 and /16 operations to extract hex digits. 3. Use %10 and /10 operations to extrcat decimal digits 4. Use itoa(int, buffer, base) function to extract ASCII codes for the digits of the number in hex/decimal.
The modulus operator (%) gives you the remainder when dividing by a number. (n % 10) will give you the least significant digit of n.
(n / 10) will strip off that digit, and the usual way to convert a number to individual digits (whether those are char or binary) is a loop that does successive modulus and division operations.