Blink Turns on an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used. */
void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off delay(1000); // wait for a second } 这段代码编译后占用1018字节,由于AVR单片机上电后所有的I/O口默认为输入端口,如果想做输出端口用,需要设置端口模式,在这段代码中,是用pinMode函数来指定端口工作模式的。
文章评论(0条评论)
登录后参与讨论