problem with multipul pwn/delay

heres how the program is settup

const int RevRelay = 11;
const int Step = 12;

void setup() {
pinMode(Step, OUTPUT);
pinMode(RevRelay, OUTPUT);
}

void loop() {
digitalWrite(Step, HIGH);
delay(4);
digitalWrite(Step, LOW);
delay(4);
digitalWrite(RevRelay, HIGH);
delay(1000);
digitalWrite(RevRelay, LOW);
delay(1000);
}

heres what it acts like

const int RevRelay = 11;
const int Step = 12;

void setup() {
pinMode(Step, OUTPUT);
pinMode(RevRelay, OUTPUT);
}

void loop() {
digitalWrite(Step, HIGH);
delay(1000);
digitalWrite(Step, LOW);
delay(1000);
digitalWrite(RevRelay, HIGH);
delay(1000);
digitalWrite(RevRelay, LOW);
delay(1000);
}

any ideas to why it dose thst dnd if their is a nother way to right it let me know thenks

What does the code have to do with PWM?

Are you expecting to see a 4 millisecond delay?

What is connected to the Step pin?

Very strange, it should not do that.

Which Arduino board do you have ?
Do you use the newest Arduino IDE version 1.0.6 or 1.5.8 ?
Are you sure that you are uploading the sketch ? Can you make a led blink ?

Delta_G, you think a step relay is used ? then 4ms is too short.

would adding a another void loop help

No. You can only have one loop() function. What were you thinking of doing with it ?

Can you tell us what the program is intended to do and what hardware you are using ?

the 4 ms is the step timer and the 1000 ms is the reverse switch

the pin 11 puts power to a bace of a NPN tranzistor alowing the steper moter to reverce and the 4 ms is makeing the steper moter step bye aplying pasitive pulces to the step pin on the bipolar driver bord from pin 12 so i want pin 12 to have a 4ms delay and the pin 11 to have a 1000 ms delay dose that make more sence

witch code do i use for what i am doing

so this code should do what i want it to do

const int Step = 12;
const int NPNRev = 11;

const int Step_Interval = 2;
const int NPNRev_Interval = 1000;

const int blinkDuration = 0;

byte Step_State = LOW;
byte NPNRev_State = LOW;

unsigned long currentMillis = 0;
unsigned long previous_Step_Millis = 0;
unsigned long previous_NPNRev_Millis = 0;

void setup() {
pinMode(Step, OUTPUT);
pinMode(NPNRev, OUTPUT);

}

void loop() {
currentMillis = millis();
update_Step_State();
updateLed_B_State();
}

void update_Step_State() {

if (Step_State == LOW) {
if (currentMillis - previous_Step_Millis >= Step_Interval) {
Step_State = HIGH;
previous_Step_Millis += Step_Interval;
}
}
else {
if (currentMillis - previous_Step_Millis >= blinkDuration) {
Step_State = LOW;
previous_Step_Millis += blinkDuration;
}
}
}
void update_NPNRev_State() {

if (NPNRev_State == LOW) {
if (currentMillis - previous_NPNRev_Millis >= NPNRev_Interval) {
NPNRev_State = HIGH;
previous_NPNRev_Millis += led_B_Interval;
}
}
else {
if (currentMillis - previous_NPNRev_Millis >= blinkDuration) {
NPNRev_State = LOW;
previous_NPNRev_Millis += blinkDuration;
}
}
}

that is how the code was wrote so i coppyed it and modifyed the variebls so it would do what i want so what needs to be fixed what line and what number

it verifies ok so i will test it

no output on the io pins what is wrong with this virshion

const int Step = 12;
const int NPNRev = 11;

const int Step_Interval = 2;
const int NPNRev_Interval = 1000;

const int blinkDuration = 0;

byte Step_State = LOW;
byte NPNRev_State = LOW;

unsigned long currentMillis = 0;
unsigned long previous_Step_Millis = 0;
unsigned long previous_NPNRev_Millis = 0;

void setup() {
pinMode(Step, OUTPUT);
pinMode(NPNRev, OUTPUT);

}

void loop() {
currentMillis = millis();
update_Step_State();
update_NPNRev_State();
}

void update_Step_State() {

if (Step_State == LOW) {
if (currentMillis - previous_Step_Millis >= Step_Interval) {
Step_State = HIGH;
previous_Step_Millis += Step_Interval;
}
}
else {
if (currentMillis - previous_Step_Millis >= blinkDuration) {
Step_State = LOW;
previous_Step_Millis += blinkDuration;
}
}
}
void update_NPNRev_State() {

if (NPNRev_State == LOW) {
if (currentMillis - previous_NPNRev_Millis >= NPNRev_Interval) {
NPNRev_State = HIGH;
previous_NPNRev_Millis += NPNRev_Interval;
}
}
else {
if (currentMillis - previous_NPNRev_Millis >= blinkDuration) {
NPNRev_State = LOW;
previous_NPNRev_Millis += blinkDuration;
}
}
}

Would writing the current states to the pins help I wonder ?

Delta_G did tell you earlier

The only thing you're doing wrong here is not setting the pins. You get the new state for the pins, but at some point you'll need to actually do a digitalWrite(Step, Step_State) to actually put that out on the pin.

so how do i do that? what do i hafto change whare dose the digitalWrite go? any tips or ideas i am clueless why i get no io

i think i got it i under sthnd how variebules and how to turn a io pin on and off but the timeing was what keps not working but with the new code ti solves the isshue but it gave mr no io i think i fixed what you said before i upload it a gin so here is the revised code just the void loop

void loop() {
digitalWrite(Step, Step_State);
digitalWrite(NPNRev, NPNRev_State);
currentMillis = millis();
update_Step_State();
update_NPNRev_State();
}

All I want to know is if i wrote the code the way you said to. Or not please check the code that I will quote.
if this will work witch it did not then tell me the issue with it please.

vinaton:
All I want to know is if i wrote the code the way you said to. Or not please check the code that I will quote.
if this will work witch it did not then tell me the issue with it please.

void loop() {
digitalWrite(Step, Step_State);
digitalWrite(NPNRev, NPNRev_State);
currentMillis = millis();
update_Step_State();
update_NPNRev_State();
}

We cannot tell you the issue with it unless you post the whole program.
For instance, have you set the output pins properly with the pinMode() command ?

I will try your suggestion thanks.

I solved my problem thanks for the help. Sorry Delta_G for all my problems with geammer. I don't write that often so I am not the best. I learned alot from this so i will have less problems.

Thanks,

Vinatron