Arduino language learning records (Continuous updates)

Source: Internet
Author: User

A treasure bought a set a few days ago, and it has no time. Today, I started to learn this "Toy ".

1. variable data type of Arduino:

Data Type
Data Type Ram Range
Void keyword N/ N/
Boolean 1 byte 0 to 1 (true or false)
Byte 1 byte 0 to 255
Char 1 byte -128 to 127
Unsigned char 1 byte 0 to 255
Int 2 byte -32768 to 32767
Unsigned int 2 byte 0 to 65535
Word 2 byte 0 to 65535
Long 4 byte -2147483648 to 2147483647
Unsigned long 4 byte 0 to 4294967295
Float 4 byte -3.4028235e38 to 3.4028235e38
Double 4 byte -3.4028235e38 to 3.4028235e38
String 1 byte + x Character array
Array 1 byte + x Variable set

 

2. Simple structure of the Arduino program:

 1   Int Tmppin = 8 ;//  Pin  2   3   //  Initialization settings  4   Void  Setup (){  5   Pinmode (tmppin, input );  6   }  7   8   //  Main Function  9  Void  Loop (){  10 }

Define variables at the beginning. Assign the pin number to a variable.
The setup and loop methods are required by Arduino. Setup is equivalent to initialization (similar to the constructor or init method). Loop is equivalent to the main method, which is the main execution method of Arduino. Unlike other languages, this method is executed repeatedly.

3. Program IO--INPUT and Output

Set I/O in pinmode in setup. There are two types of Arduino: one input source and the other output source. Use the pinmode method to set the effect of pins.

4. digitalread and digitalwrite

 1   Int Tmppin1 = 8  ;  2   Int Tmppin2 =9  ;  3   4   Void  Setup (){  5   Pinmode (tmppin1, input );  6   Pinmode (tmppin2, output );  7   }  8   9   Void  Loop (){  10      Int Pinstate = Digitalread (tmppin1 );  11   Digitalwrite (tmppin2, high );  12 }

 

Status of the digitalread read pin
Digitalwrite outputs the status to the pin, which is divided into 0 and 1, replaced by low and high respectively.

5. logical operators

&, | ,!

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.