网站大量收购独家精品文档,联系QQ:2885784924

Arduino - 数据类型.pdf

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Arduino - 数据类型

Arduino - 数据类型 C 中的数据类型是指⽤于声明不同类型的变量或函数的扩展系统。 变量的类型确定它 在存储器中占⽤ 少空间以及如何解释存储的位模式。 下表提供了您将在Arduino编程期间使⽤的所有数据类型。 void Boolean char Unsigned char byte int Unsigned int word long Unsigned long short float double array String-char array String-object void void关键字仅⽤于函数声明。 它表⽰该函数预计不会向调⽤它的函数返回任何信息。 例⼦ Void Loop ( ) { // rest of the code } Boolean 布尔值保存两个值之⼀,true或false 。 每个布尔变量占⽤⼀个字节的内存。 例⼦ boolean val = false ; // declaration of variable with type boolean boolean state = true ; // declaration of variable with type boolea Char ⼀种数据类型,占⽤存储字符值的⼀个字节的内存。 字符⽂字⽤单引号写成:\A\ ,对 于 个字符,字符串使⽤双引号:“ABC 。 但是,字符存储为数字。 您可以在 ASCII 图表中查看特定编码。 这意味着可以对字 符进⾏算术运算,其中使⽤字符的ASCII值。 例如,\A\+ 1的值为66 ,因为⼤写字母 A的ASCII值为65 。 例⼦ Char chr a = ‘a’ ;//declaration of variable with type char and ini Char chr c = 97 ;//declaration of variable with type char and init unsigned char ⽆符号字符是⼀种⽆符号数据类型,占⽤⼀个字节的内存。 unsigned char数据类型对0 到255之间的数字进⾏编码。 例⼦ Unsigned Char chr y = 121 ; // declaration of variable with type U byte ⼀个字节存储⼀个8位⽆符号数,从0到255 。 例⼦ byte m = 25 ;//declaration of variable with type byte and initiali int 整数是数字存储的主数据类型。 int存储16位(2字节)值。 这产⽣-32,768⾄32,767的范 围(最⼩值为-2 ^ 15 ,最⼤值为(2 ^ 15)-1) 。 int ⼤⼩因板⽽异。 例如,在Arduino Due 中, int 存储32位(4字节)值。 这产 ⽣-2,147 ,483,648⾄2,147 ,483,647(最⼩值-2 ^ 31和最⼤值(2 ^ 31)-1)的范围。 例⼦ int counter = 32 ;// declaration of variable with type int and ini Unsigned int ⽆符号整数(⽆符号整数)与存储2字节值的⽅式相同。 然⽽,它们不是存储负数,⽽ 是存储正值,产⽣0到65,535(2 ^ 16)-1的有⽤范围。 Due存储4字节(32位)值,范围从0 到4 ,294 ,967 ,295(2 ^ 32-1) 。 例⼦ Unsigned int counter = 60 ; // declaration of variable with type unsigned int and initialize it with 60 Word 在Uno和其他基于ATMEGA的主板上,⼀个字存储⼀个16位⽆符号数。 在到期和零 时,它存储⼀个32位⽆符号数。 例⼦ word w = 1000 ;//declaration of variable with type word and initia Long 长变量是⽤于数字存储的扩展⼤⼩变量,并存储32位(4字节) ,从2,147 ,483,648到 2,147 ,483,647 。 例⼦ Long velocity = 102346 ;//declaration of variable with type Long a unsigned

文档评论(0)

ayangjiayu4 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档