setup()関数後に実行したいプログラムを書きます。
C言語標準プログラムでいう main()関数にあたります。
イメージ的には、
●記述
void loop()
[c]
void main(void)
{
while(1){
}
}
[/c]
のwhileの中を書くようなイメージです。
●Example from Arduino Web Site
[c]
const int buttonPin = 3;
// setup initializes serial and the button pin
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
// loop checks the button pin each time,
// and will send serial if it is pressed
void loop()
{
if (digitalRead(buttonPin) == HIGH)
Serial.write(‘H’);
else
Serial.write(‘L’);
delay(1000);
}
[/c]