Go Down

Topic: Need help!! (Read 615 times) previous topic - next topic


LED program not working need help dont know why

Below is code
Code: [Select]
void setup (){

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


LED program not working need help dont know why

Below is code
Code: [Select]

  for ( counter=0; counter = 5; counter++){

Well, I have no idea what the code is supposed to do.  You should probably tell what you want it to do.  I don't have a crystal ball and I can't read minds.

I have no idea what actually happens.  You should probably tell that too.  I mean if you really want help.

But I do know that this for loop will never execute.  On the very first iteration counter is 0 and the condition to run the loop says it has to equal 5.  0 != 5 so the loop will never run.
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D


ok well 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


Mar 01, 2013, 03:27 am Last Edit: Mar 01, 2013, 03:29 am by Arrch Reason: 1
You must have missed the thread titled Read this before posting a programming question.

But, to get you started, you should look at a few examples of for loop to see how they work, because I sincerely doubt this piece
Code: [Select]

   for ( counter=0; counter = 5; counter++){

is doing what you think it's doing.


Start by correcting this typo, it would make some progress. Then repost the code and tell us what you expect from it and what you got.

Code: [Select]

for ( counter=0; counter < 5; counter++) {

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131