mrr1995:
hi everyone,i have a small problem.in my codes,i want to use array that have only 1 or zero but i assigned them as int.so,when i use array,the variables that filled with those array unit will be byte but either 1 or zero.i only need 1 or zero for my purpose so is this true??:int sega[] = {1,0,1,1,0,1,1,1,1,1}; //this is my array
q1=sega[s1]; //s1 is a number between 0 and 9
digitalWrite(0,q1); //i want to write on the pin0are they true?or i must use bool arrays instead of int??
With number values, zero is false and not-zero is true. You can use the ! operator to flip that if need be.
edit: example below
Why use a 16-bit int where and 8-bit byte (yes, byte is an Arduino variable type) will do?
Arduino type bool is a byte that can ONLY be 0 or 1.
Then at least you only waste 7 bits instead of 15.
All variables are arrays of bits that you can operate on as individuals or as a group.
You can use the Arduino bit command words, the bitRead(x,n) pages has links to the others, like bitWrite(x,n);
edit --- working example of using the ! operator is posted below.