2017년 4월 8일 토요일

[Arduino Uno R3] To use buzer by analogWrite.

It's very easy to use buzer.
Buzer can be connected to + and -.
By analogWrite, you should to send value 255/2 to buzer.
If you want stop buzer sound. you should to send value 0 to buzer.


Following is code to use buzer.
// you don't need to write any code into setup()
void setup() {

}

// the loop routine runs over and over again forever:
void loop() {
  analogWrite(9, 255/2);  // buzer sound 
  delay(1000);
  analogWrite(9,0);         // no buzer sound
  delay(1000);
}

댓글 없음:

댓글 쓰기