# Changing Hertz of LED

Hello, I am trying to do an assignment for a class and I am stuck.

I have to change a 1 Hz to 2 Hz and I cannot figure out how,

this is the coding for 1 Hz

void setup() { pinMode(2,OUTPUT); }

void loop() { digitalWrite(2,HIGH); delay(500); digitalWrite(2,LOW); delay(500);

}

Do I have to change the PWM? Or....

You want it to go twice as fast, so change the delay to 1/2 as much.

koalek: Hello, I am trying to do an assignment for a class and I am stuck.

I have to change a 1 Hz to 2 Hz and I cannot figure out how,

this is the coding for 1 Hz

void setup() { pinMode(2,OUTPUT); }

void loop() { digitalWrite(2,HIGH); delay(250); digitalWrite(2,LOW); delay(250);

}

Do I have to change the PWM? Or....

I'd love Australia to adopt Arduino as a teaching aid at schools here .

It couldn't me more obvious that this is a school assignment. Why do you do the work for the student instead of telling that student how to work it out (as was already done by CrossRoads) ? If you'd love to have schools use Arduino, you like to have people learn from it. Teaching isn't done by doing the work for a student, but having that student figuring out how to do it himself.

No the answer wasnt givn- a "Hint" was given. Possibly a big hint, but for the simple question here, I have a hard time thinking of how to make it smaller, without being in closer dialog with the student.

Msquare: No the answer wasnt givn- a "Hint" was given.

In this case, I might have first checked if the student realized that `Period(frequency) = inverse-of interval(duration`). By then asking him/her about what defined the duration in this code, they might have come to the conclusion that the delay needed to be shorter. Secondly I might have asked what the OP meant by "PWM" at the end? (I still wonder why that was an afterthought in the question - there may have been a total mixup in the students mind - due to the course material - between analog and digital write, a blinking LED and a dim LED (which is blinking to achieve the effect...) )