AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Tutorial on making a void pantograph2/14/2023 ![]() ![]() ![]() FunctionsĪ function (otherwise known as a procedure or sub-routine) is a named piece of code that can be used from elsewhere in a sketch. There's more information in the Variables tutorial. For example, you could store the value read from an input into a variable. Often, however, the value of a variable will change while the sketch runs. ![]() The advantage of using a variable is that it's easier to move the LED to a different pin: you only need to edit the one line that assigns the initial value to the variable. In this case, the person writing the program could have chosen not to bother creating the ledPin variable and instead have simply written 13 everywhere they needed to specify a pin number. Every time the name ledPin appears in the code, its value will be retrieved. It's being used to indicate which Arduino pin the LED is connected to. For example, the line from the Blink sketch above declares a variable with the name ledPin, the type int, and an initial value of 13. ![]() VariablesĪ variable is a place for storing a piece of data. The message "LED connected to digital pin 13" is a comment. Int ledPin = 13 // LED connected to digital pin 13 ![]()
0 Comments
Read More
Leave a Reply. |