![]() That is a tiny function that takes in information and modifies it. If you say x = 2, then the result will be 4. Some functions take in information, change it, and spit out something different. They're basically groups of code that run together. Without slowing down the program, the LED will only be turned off until the computer reaches the top of the loop again- less than 1/10th of a second later.įunctions are everywhere in programming. Why do you need the second delay? Because the loop() runs over and over again. To turn the LED off, you'll use digitalWrite() again with a LOW argument. The number you give to delay is measured in milliseconds, and 1000 milliseconds is one second. ![]() How much time? That's what the argument inside the delay() parentheses is for. There are no MIDDLE or MEDIUM commands.ĭelay() is a function that pauses your program for a set amount of time. digitalWrite also needs two arguments: pin number, and HIGH or LOW. ![]() In this loop, you use the digitalWrite() function to turn the LED on. You see them on line 5 of void loop occurs over and over again. PinMode commands happen between the curly braces that define the void setup(). You will learn more about the differences later. The first is the pin number, the second is whether that pin number should be used as an OUTPUT, INPUT, or INPUT_PULLUP. pinMode needs two arguments, or pieces of information, given to it. To do that in code, you use the pinMode() function. The first step in this program is to tell Maker Board which pin number holds the LED you'll light.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |