📜  arduino 按钮下一个数组 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:26.233000             🧑  作者: Mango

代码示例1
int arrayName[10]={1,2,3,4,5,6,7,8,9,0}    //your array
int arrayPosition=0;                    //the position of your array. Dont let it get bigger than the array

void loop(){
    serial.println(arrayPosition);        
    if(buttonPressed){        //debounce this
        arrayPosition++        //incrament this value when the button is pressed
        if(arrayPosition==11){    //reset it if it gets bigger than the array
            arrayPosition=0;
        }
    }
}