Welcome to the Parallax Discussion Forums, sign-up to participate.

I want to use the potentiometer to provide input to a neural network, so I want to convert the rctime number to a binary number, and then separate it into 1 digit lengths.

For example, say the potmeter gives the rctime value of 323. In binary it would be 0101000011. Then in a format understandable by the neural net, it would be split, literally, into 10 separate digits, i.e. 0, 1, 0, 1, 0, 0, 0, 0, 1, and 1. Each of these would be stored as a variable (or a constant?).

Another example would be the number 700 (around the max of the potmeter). In binary it would be 1010111100. So again, split into 10 digits this would be: 1, 0, 1, 0, 1, 1, 1, 1, 0, and 0.

So the steps pbasic would have to perform would be as follows:

1. Take the number of the current rctime and convert it to binary.

2. Take that binary number and split it into 10 separate digits.

3. Store each of those digits as a variable.

I've been trying to look through the documentation, trying to figure out how to do this. Can anybody help me?

For example, say the potmeter gives the rctime value of 323. In binary it would be 0101000011. Then in a format understandable by the neural net, it would be split, literally, into 10 separate digits, i.e. 0, 1, 0, 1, 0, 0, 0, 0, 1, and 1. Each of these would be stored as a variable (or a constant?).

Another example would be the number 700 (around the max of the potmeter). In binary it would be 1010111100. So again, split into 10 digits this would be: 1, 0, 1, 0, 1, 1, 1, 1, 0, and 0.

So the steps pbasic would have to perform would be as follows:

1. Take the number of the current rctime and convert it to binary.

2. Take that binary number and split it into 10 separate digits.

3. Store each of those digits as a variable.

I've been trying to look through the documentation, trying to figure out how to do this. Can anybody help me?

Tagged:

## Comments

6 Commentssorted by Votes Date Added0Vote UpVote DownYou could create an array for each bit of the number and read the bits into the array something like the following

Jeff T.

0Vote UpVote Down▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Chris Savage

Parallax Engineering

50 72 6F 6A 65 63 74 20 53 69 74 65

·

Engineering Tech, Parallax Inc.

(916) 624-8333 x3005

Website / Twitter / Google+

0Vote UpVote DownThanks Unsoundcode, I'm not sure what the heck you explained to me, but I may be able to figure it out =)

Apologies, I am still new at programming.

0Vote UpVote Down·http://www.savagecircuits.com/

is that new or have I been to blind to see it , neat link.

Jeff T.

0Vote UpVote Down▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Chris Savage

Parallax Engineering

50 72 6F 6A 65 63 74 20 53 69 74 65

·

Engineering Tech, Parallax Inc.

(916) 624-8333 x3005

Website / Twitter / Google+