Go Down

Topic: 4 led chaser problems. (Read 626 times) previous topic - next topic

nemoskull

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.

please help me.
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{
  valdirA = digitalRead(dirA);

  valstepA = digitalRead(stepA);
 
digitalWrite(posA, valstepA);

} while (valstepA == HIGH);

posA ++;





}
   
 


LarryD

int valstepA = 0;
int valdirA = 0;

Do you want boolean ?
boolean valstepA = false;
boolean valdirA = false;
The way you have it in your schematic isn't the same as how you have it wired up!

fungus


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

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

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