From the course: Learning Arduino: Foundations
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Example: Coding a digital traffic signal - Arduino Tutorial
From the course: Learning Arduino: Foundations
Example: Coding a digital traffic signal
- [Instructor] So now, for the coding, the very first thing that we need to do is to initialize the variables. So I'll go ahead and add it outside the void setup function. So I'll initialize integer GreenLED that's connected to pin 10. And I'll do the same for the other LEDs. So the second thing is that I need to set each LED to be as an output. So we do so by going to the void setup function. And then I use pin mode. And then I write down the same name that I initialized for the variable, which is GreenLED. Make sure that you give the same name, and then as output. So I'll do the same thing for the other two LEDs. So I'll copy the same function. And in order to make sure that I give the right name, I'll just copy the name from the top. So this is for the yellow and then, finally, for the red. So one of the things that we usually do in such examples is that we want to make sure that the LEDs are off to start with. So to do…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.