Go Down

Topic: LED project need help!! (Read 762 times) previous topic - next topic

TheSpook

LED program not working need help dont know why

im creating a program on vb that controls leds the vb program generates a 5bit binary number which i have then ported to arduino. i then want arduino to read each bit separately and then check if its a 1 or 0

Below is code
Code: [Select]
void setup (){
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  Serial.begin(9600);
 
}

void loop(){
  int Portresult;
  int val;
  int bitval;
  int counter = 0;
   for ( counter=0; counter = 5; counter++){
     
     bitRead(Portresult,counter);
     
      val=bit(counter);
      counter = counter + 2;
      if(val=='1') { digitalWrite(counter,HIGH) ; }
      else if (val=='0') {digitalWrite(counter,LOW);
   }
}
}

spatula

Hi, this is your third post on the same topic, and you are just repeating your question without following the advice people already gave you. Using the reply button under one of your previous posts may get you more help.

Go Up