help me fot , for loop program


hello friends;
i want save each bit of byte in separate variable. example, 1110101,
 1 save in a0,0 save in a1, 1 save in a2, 0 save a3,...
my code follows not run.

int a=11110001;
int led1=3;
void setup() {
  // put setup code here, run once:
pinmode(led1,output);
}

void loop() {
  //put main code here, run repeatedly:
for (int i=0;i<=8;i++){
 int b= bitread(a,i);
 if (b[0]==1){
  digitalwrite(led1,high);
  delay(5000);
 }
}
}

code: [select]
int a=11110001;
hit reference pages, , see range of values fit in int.

bitread() getting bits binary data, not decimal data.


Arduino Forum > Using Arduino > Programming Questions > help me fot , for loop program


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts