Go Down

### Topic: 4 led chaser problems. (Read 1 time)previous topic - next topic

#### nemoskull

##### Jan 17, 2013, 01:18 am
so i have 4 leds. i have a second arduino pulsing every second. the second arduino is fed straight wire into A3. i do a digital read on A3 and get a value i then use in a digital write.
the val POSA starts at 6 and needs to go up to 9, then repeat to 6.

i use a loop and i get theh led to mirror the second arduino pulsing. blink blink.
now when i add the code
posA ++;
or
posA =  posA + 1;
the program blinks the first led on pin 6, then does nothing.

Code: [Select]

int A = 6;
int B = 7;
int C = 8;
int D = 9;

int stepA = A3;
int dirA = A2;
int stepB = A1;
int dirB = A0;

int valstepA = 0;
int valdirA = 0;

int posA = 6;

void setup() {
// put your setup code here, to run once:

pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);

pinMode(stepA, INPUT);
pinMode(dirA, INPUT);
pinMode(stepB, INPUT);
pinMode(dirB, INPUT);

}

void loop() {
// put your main code here, to run repeatedly:

do{

digitalWrite(posA, valstepA);

} while (valstepA == HIGH);

posA ++;

}

#### larryd

#1
##### Jan 17, 2013, 02:16 am
int valstepA = 0;
int valdirA = 0;

Do you want boolean ?
boolean valstepA = false;
boolean valdirA = false;
No technical PMs.
The last thing you did is where you should start looking.

#### fungus

#2
##### Jan 17, 2013, 01:11 pm

the val POSA starts at 6 and needs to go up to 9, then repeat to 6.

Which part of the code does "then repeat to 6"?

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### nemoskull

#3
##### Jan 17, 2013, 06:17 pm
larryD, i dont know if booean works better here. im comming from ASM and am still new to C.\\

fungu, that bit of code was after "posA ++;"
but seems to have been deleted.

#### fungus

#4
##### Jan 17, 2013, 07:21 pm
I suspect that if valstepA is LOW then posA is going to get incremented a lot more often that you think.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up