In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what the basic functions of Arduino are, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
One of the lessons to be done between learning a language is to understand the framework of the program, which is equally simple and can be divided into several parts.
1. Declare variables and interface names (int val;int ledPin=13;).
2. Setup ()-- the function is used at the beginning of the program to initialize variables, interface modes, enable libraries, and so on (for example: pinMode (ledPin,OUTUPT);).
3. Loop ()-- after the setup () function, that is, after initialization, loop () allows your program to be executed in a loop. Use it to run Arduino.
Next, let's learn a few basic functions.
1. PinMode (interface name, OUTPUT or INPUT) defines the-- interface as the input or output interface, which is used in the setup () function.
2. DigitalWrite (interface name, HIGH or LOW)-sets the digital interface value to a high or low value.
3. DigitalRead (interface name)-read out the value of the digital interface.
4. AnalogWrite (interface name, numerical value)-writes an analog value (PWM wave) to an interface. For Arduino of ATmega168 chip (including Mini or BT), this function can work on interfaces 3, 5, 6, 9, 10 and 11. The USB and serial Arduino of the old ATmega8 chips only support interfaces 9, 10 and 11.
5. AnalogRead (Interface name)-reads the value from the specified analog interface, and Arduino converts the analog value to 10-bit. This method converts the input 0-5 voltage value to an integer value between 0 and 1023.
6. Delay ()-delay for a period of time, delay (1000) is one second.
7. Serial.begin (baud rate)-sets the rate at which serial data is transmitted per second (baud rate). When communicating with a computer, use the following values: 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600 or 115200. You can also use other values at any time, for example, a special baud rate is required to communicate with Jack 0 or Jack 1. Used in the setup () function
8. Serial.read ()-- reads data that is continuously entered.
9. Serial.print (data, the base of data)-- output data from the serial port. Serial.print (data) defaults to decimal equals Serial.print (data, DEC).
10. Serial.println (data, the base of data)-outputs data from the serial port, followed by a carriage return and a newline character. This function takes the same value as Serial.print ().
About the basic functions of Arduino which are shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.