Keyestudio ARDUINO maker learning kit Manual page 47

Table of Contents

Advertisement

keyestudio
Sample program
//////////////////////////////////////////////////////////
int buzzer=8;// select digital IO pin for the buzzer
void setup()
{
pinMode(buzzer,OUTPUT);// set digital IO pin pattern, OUTPUT to be output
}
void loop()
{ unsigned char i,j;//define variable
while(1)
{ for(i=0;i<80;i++)// output a frequency sound
{ digitalWrite(buzzer,HIGH);// sound
delay(1);//delay1ms
digitalWrite(buzzer,LOW);//not sound
delay(1);//ms delay
}
for(i=0;i<100;i++)// output a frequency sound
{ digitalWrite(buzzer,HIGH);// sound
digitalWrite(buzzer,LOW);//not sound
delay(2);//2ms delay
}
}
}
//////////////////////////////////////////////////////////
After downloading the program, buzzer experiment is finished.
*******************************************************************************
www.keyestudio.cc
45

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ARDUINO maker learning kit and is the answer not in the manual?

Table of Contents