[英]Array to remove a number on arduino
如何打印和刪除數組中的這個數字? 我正在嘗試做數組,但它不起作用:
我有一個帶有這個數字的if
:
if (conteudo.substring(1) == "44 46 00 22")
所以我想在我的數組中打印這個數字並在之后刪除。
int ledArray[] = {44 46 00 22,44 46 00 23,44 46 00 24};
for(int i = 0; i <= 4; i++)
{
{
Serial.println(ledArray[0]);
}
幾個不同的點。
1) 不確定這是否能回答您的問題,但您的代碼中應該有ledArray[i]
的問題是...
for(int i = 0; i <= 4; i++){ {
Serial.println(ledArray[i]);
}
代替
for(int i = 0; i <= 4; i++){ {
Serial.println(ledArray[0]);
}
3) int
數組不能按您希望的方式工作。 它不會包含空格 - 數組的每個成員只是一個不同的整數,類型為int
看起來您有 4 個值,它們很可能是十六進制而不是十進制(十進制 0-255:十六進制 00 - FF),所以我建議使用二維數組...
// choose one of the definitions below depending on whether you numbers are decimal or HEX - in HEX the numbers start 0x
int ledArray[3][4] = {{44, 46, 00, 22},{44, 46, 00, 23},{44, 46, 00, 24}};
// int ledArray[3][4] = {{0x44, 0x46, 0x00, 0x22},{0x44, 0x46, 0x00, 0x23},{0x44, 0x46, 0x00, 0x24}};
for(int i = 0; i < 3; i++)
{
for(int j = 0; j<4;j++)
{
Serial.println(ledArray[i]);
}
// insert something here for a pause before you print the next set of numbers
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.