In my project I need to get different numbers which then turn on leds and make a few servo motors to move but I was wondering how would you type this into the software. I want to select 1 to 30 integers. How can I do that. if (son = (1 to 30)); {
If the numbers are fixed, just put them in an array :
const int numbers[] = {1,6,3,26, etc };
Ir you want random numbers, use the rand() function.
Allan
I would type them in binary format and store them as an array of unsigned long.
unsigned long mySequence[] = {
0b000000000000000000000000000000, // all LEDs off
0b000000001100000000000100000000, // LEDs 7, 20, 21
0b000010000000000000100000010000, // LEDs 4, 12, 25
...
};
Then you can use bitRead() function to find which digits are set to 1 indicating which LEDs should be lit.
PlzHelpMe873:
In my project I need to get different numbers which then turn on leds and make a few servo motors to move but I was wondering how would you type this into the software. I want to select 1 to 30 integers. How can I do that. if (son = (1 to 30)); {
That is not very clear. Please give some examples of the numbers and what should happen when they are selected.
...R