arduino基础问题_端口如何统一命名
想实现如下功能:int mypin[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,a0,a1,a2,a3,a4,a5}
前面14个是数字口,后面6个为拟模口。
但每明显a0的数据类型不是int的,所以报错。
请教我应该如何把所有的模拟口也放到变量里,另起一个数组也行。不要告诉我把int改为string,那样也不行,digitalRead不接受string类型。
本帖最后由 histamine 于 2013-3-18 11:29 编辑
pins_arduino.h
static const uint8_t A0 = 14;
static const uint8_t A1 = 15;
static const uint8_t A2 = 16;
static const uint8_t A3 = 17;
static const uint8_t A4 = 18;
static const uint8_t A5 = 19;
static const uint8_t A6 = 20;
static const uint8_t A7 = 21;
:lol
写成
uint8_t mypin[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A4,A5};
就行了 想问一下,如何直接digitalRead【14】脚就是读取a0的值吗? A0,A1,A2,A3,依次是14,15,16,17号端口,以此类推。 那我没必要把14转来 a0,直接如下就可以了
int mypin[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}
回家就测试一下,成功了来结贴。:):):):):):):):):D:D:D:D:D:D
本帖最后由 openmmoo 于 2013-3-18 11:40 编辑
那我没必要把14转来 a0,直接如下就可以了
int mypin[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}
回家就测试一下,成功了来结贴。
:):):):):):):):):D:D:D:D:D:D
又解决一个问题。学点东西真不容易呀!
好在有极客工仿。 为什么我看Arduino.h中,函数传递进去的都是uint_8呢? znstj 发表于 2015-4-8 15:56 static/image/common/back.gif
为什么我看Arduino.h中,函数传递进去的都是uint_8呢?
stdint.h中的.
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed int int16_t;
typedef unsigned int uint16_t;
typedef signed long int int32_t;
typedef unsigned long int uint32_t;
定一些常用的int类型而已.
页:
[1]