For example, “13” is assigned to the terminal to which the LED was externally connected last time. The interface that connects the electronic components to the Arduino is numbered. The following description on the first line names the terminal number to which the electronic component is connected. This section describes the contents described in programs other than digital output. If you want to turn off the LED, specify “LOW” so that the terminal becomes 0V. If you connect an LED this time, electricity will be supplied, and the LED will light up. If the terminal status is specified as “HIGH,” 5V is output. The pin number is specified as “LED_PIN” like pinMode (). Specify the terminal number of the target whose output is to be changed and the order of output to the terminal. The output is changed by “digitalWrite ()” on the 8th line. This time, since the 13th terminal is used, the target terminal is “13,” and when using the digital output mode, specify “OUTPUT.” However, since the terminal number is set to be used with the name “LED_PIN” this time, the target terminal number is specified as “LED_PIN” (described later). In pinMode (), specify the target pin number and the mode to be used in parentheses. ![]() This setting is “pinMode ()” on the 4th line. For this reason, it’s necessary to specify in advance the setting to use. In digital input/output, there are two methods of use: “digital output” that can change the terminal status and “digital input” that reads the terminal status. Lines 4 and 8 are important when controlling digital output. Create a program, write it to Arduino as explained previously, and check that the LED lights up. This section describes how to turn on the LED connected to the 13th digital input/output terminal. Let’s turn on the LED by controlling the digital output with a program. In Arduino, when the voltage is high, the terminal voltage is “5V,” and when it’s low, it switches to “0V.” The high voltage state is called “HIGH” and the low voltage state is called “LOW.” When specifying by program, specify “HIGH,” “LOW.” Digital input and analog input will be introduced later in this series. Conversely, if the voltage is low, the LED can be turned off. You can freely switch between two states: “High” or “Low.” For example, if an LED is connected and the voltage is high, the LED will turn on. A number is assigned to each terminal, and this number is specified when the electronic components are controlled by the program.ĭigital output is an interface that can change the state of each pin from a program. On the other hand, the analog input is a terminal that can input a continuous voltage change. The digital input/output terminal outputs have two states: “high state” and “low state,” to operate the electronic component and check the voltage state. Various controls are possible, such as connecting an LED or motor here to control the operation, connecting a switch or the like to determine on/off, or connecting a temperature sensor to measure the room temperature.Īrduino UNO has 14 (0 to 13) “digital input/output” terminals on the top and six (A0 to A5) “analog input” terminals on the lower right. LED is connected to resistance and lights upĪrduino has socket-like terminals arranged one above the other as an interface for connecting and controlling electronic components.Operating the electrical currents by using resistance.In addition, to use electronic parts, it’s important to understand terms related to electricity, such as “voltage” and “current.” If you don’t understand the meaning of these terms, you won’t be able to determine whether they’re suitable for your intended use when purchasing electronic components. This time, we’ll explain the digital output that can be switched on and off with Arduino, and introduce how to create a digital output program using LEDs. Kazuhiro Fukuda, who is famous for Arduino introductory book, will be instructing throughout the article. ![]() So, this time we’ll be delivering the basic “key” to Arduino electronics. This article was translated to English, and was originally published for deviceplus.jp.ĭevices Plus introduced a variety of applications and examples of Arduino, but basic knowledge is still important for making anything!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |