访问arduino数组中的值范围

accessing range of values in arduino array

我在 Arduino 中有这样的数据包进来。

数据:12345678901234

我可以使用下面的代码访问第 5 个值。

id = sx1272.packet_received.data[4]; 

我的问题是如何访问一系列值?

我试过了,但是冒号会报错。

char[2] id; 

if( sx1272.packet_received.length > 4 )
{
id = sx1272.packet_received.data[4:5]; 
} 

C++ 中的数组不允许使用此语法。

你应该做的是这样的:

char[2] id; 

if( sx1272.packet_received.length > 5 )
{
    id[0] = sx1272.packet_received.data[4];
    id[1] = sx1272.packet_received.data[5];
}