Arduino Hello 2

Source: Internet
Author: User

Preparation
I didn't buy the original board. I purchased the compatible board from the authorized supplier. The compatible board has some changes.
In order to connect the computer with the source board and the compatible board, you not only need to connect the cable, but also need to download the corresponding driver for the compatible board I purchased to use USB cable connection, the driver depends on the compatible board. Contact the supplier. Note that different drivers are required for different operating systems, such as Windows, Mac OS X, and Linux.
 

--------------------------------------------------------------------------------
Arduino Hello 2 Description
The situation of the source board is unclear. The compatible board I purchased has a total of 14 digital ports numbered 0 ~ 13, can be used for input and output, with the help of a multimeter with the measurement frequency function can test other ports.

--------------------------------------------------------------------------------
Arduino Hello 2 Program
[Cpp] int pin = 12;
Void setup ()
{
PinMode (pin, OUTPUT );
}
Void loop ()
{
DigitalWrite (pin, HIGH );
Delay (50 );
DigitalWrite (pin, LOW );
Delay (50 );
}

Int pin = 12;
Void setup ()
{
PinMode (pin, OUTPUT );
}
Void loop ()
{
DigitalWrite (pin, HIGH );
Delay (50 );
DigitalWrite (pin, LOW );
Delay (50 );
}
--------------------------------------------------------------------------------
Arduino Hello 2 program structure
[Cpp] int pin = 12;

Int pin = 12; declare a variable pin with a value of 12 to represent pin 12. Of course, you can also directly use a value.
[Cpp] pinMode (pin, OUTPUT );

PinMode (pin, OUTPUT); set the pin mode to the OUTPUT mode. The same pin in Arduino can be used as the OUTPUT mode or as the input mode. Therefore, you need to set the mode first.
[Cpp] digitalWrite (pin, HIGH );

DigitalWrite (pin, HIGH); outputs a HIGH level to the pin.
[Cpp] delay (50 );

Delay (50); latency: 50 milliseconds. Delay is a latency function.
[Cpp] digitalWrite (pin, LOW );

DigitalWrite (pin, LOW); outputs a LOW level to the pin.
[Cpp] delay (50 );

Delay (50); latency: 50 milliseconds.


--------------------------------------------------------------------------------

Click the "file" menu and click the "Download" menu item. Arduino IDE automatically compiles the program and downloads it to the Arduino board. Use the measurement frequency function of the multimeter to test the GND pin and the 12 pin. We can see that the frequency value is 9.994Hz, but it does not reach the expected 10Hz. This is because the program requires a certain amount of execution time. The following data is available for adjusting different latency values.

Parameters of the two delay functions (unit: milliseconds) frequency (unit: Hz) remove the time specified by the delay function for each loop.
50 9.994 100060 microseconds 60 microseconds
49 10.19 98135 microseconds 135 microseconds
5 99.80 10020 microseconds 20 microseconds
4 124.7 8019 microseconds 19 microseconds
3 166.1 6020 microseconds 20 microseconds
2 248.8 4019 microseconds 19 microseconds
1 495.8 2016 microseconds 16 microseconds
0 62.10 K 16.103 microseconds 16.103 microseconds
No function 115.2 K 8.680 microseconds 8.680 microseconds
According to the above data, the execution of digitalWrite takes about 4 microseconds, while that of delay does not include latency.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.