I can't print number inside an array in Arduino -


i want print value in array (array name array_index) write of variable name bit_1. when tried enter inside array, value show zero. please advise me how correct way in arduino.

this code:

int test_number = 0; unsigned int array_index[] = {}; int bit_1 = 0; int andbit = 0; int arrsize = 0;  void setup() {   serial.begin( 9600 ); }  void loop() {   int count = 0;   test_number = random(10);   serial.println(test_number);   (bit_1 = 0; bit_1 <= 15; bit_1++)   {     andbit = test_number & 1;      if (andbit == 1)     {       array_index[count] = bit_1;       //serial.println(array_index[count]);       count=count++;     }     else     {     }     test_number = test_number >> 1;     int arrsize = sizeof(array_index) / sizeof( int );     serial.println(arrsize);     (int y = 0; y < arrsize; y++)     {       serial.println(array_index[y]);     }   }   while(1)   {    }  } 

unsigned int array_index[] = {}; array 0 elements.

you should define unsigned int array_index[16];.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -