Placing variables inside a function

My understanding is that you always use the = sign when giving a variable a value.
The textbook that I am using does not do this.
The textbook code to make a diode blink 29 times is as follows:
const int ledPin = 13;
const int delayPeriod = 250;
void setup() {
pinMode (ledPin, OUTPUT);
}
void loop() {
flash (20, delayPeriod);
delay (3000);
}
void flash(int numFlashes, int d) {
for (int i=0; i < numFlashes; i++) {
digitalWrite (ledPi, HIGH);
delay (d);
digitalWrite (ledPin, LOW);
delay (d);
}
}

My problem is understanding why numFlashes and d are not given a value with an = sign.
Please help!

void flash(int numFlashes, int d) is a function with numFlashes and d as parameters.

When you call it with flash (20, delayPeriod);, the compiler assigns the values of 20 to numFlashes and delayPeriod to d "behind the scenes."

1 Like
digitalWrite (ledPin, HIGH);

Many thanks

Thank you for your precise and clear explanation of my forum question,

Much appreciated,
Regards
Dave

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.