Pages: [1]   Go Down
Author Topic: 4 led chaser problems.  (Read 557 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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 ++;





 }
   
 
Logged

Offline Offline
Faraday Member
**
Karma: 69
Posts: 2874
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

int valstepA = 0;
int valdirA = 0;

Do you want boolean ?
boolean valstepA = false;
boolean valdirA = false;
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5759
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"?

Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5759
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect that if valstepA is LOW then posA is going to get incremented a lot more often that you think.

Logged

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

Pages: [1]   Go Up
Jump to: