hi
i was experimenting with an arduino and i uploaded the following example
to two atmega328
but the outcome is not the same!!! although both atmega328 use the same code
and same setup / buzzer, the sound pitch is different...how can that be possible?
i was experimenting with an arduino and i uploaded the following example
to two atmega328
Code:
/*
Piezo
This example shows how to run a Piezo Buzzer on pin 9
using the analogWrite() function.
It beeps 3 times fast at startup, waits a second then beeps continuously
at a slower pace
*/
void setup() {
// declare pin 9 to be an output:
pinMode(9, OUTPUT);
beep(50);
beep(50);
beep(50);
delay(1000);
}
void loop() {
beep(200);
}
void beep(unsigned char delayms){
analogWrite(9, 20); // Almost any value can be used except 0 and 255
// experiment to get the best tone
delay(delayms); // wait for a delayms ms
analogWrite(9, 0); // 0 turns it off
delay(delayms); // wait for a delayms ms
}
but the outcome is not the same!!! although both atmega328 use the same code
and same setup / buzzer, the sound pitch is different...how can that be possible?