From the course: Learning Arduino: Foundations

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

digitalWrite()

digitalWrite()

- All right, so the second function that we are going to use is digitalWrite. We use it if the digital pin has been configured as an output using a pin mode. The digitalWrite function outputs a value on that specific pin. So this is the way that we write the function digitalWrite, pin, and the value. The pin is for the configured pin that we want to specify, and the value is high or low. So if we take the same example, the same previous example with LED. Now, if we want to turn on the LED, we send high value. So digitalWrite on pin two, and then high. Now, if we want to turn it off, we send a low value. We write the digitalWrite function inside the void loop function. So the way to write it is digitalWrite And notice you that the color changes to orange indicating that the function is correct. And then the first parameter is the pin which is again, we're using pin two. And then finally sending, if I wanted to turn…

Contents