PWM 2 delay

Dit topic is gesloten

Hi all, I have an Arduino en ik programmeer al 30 jaar in c++ etc.

Met PWM maakte ik de noten, maar alles op gehoor! En nu is mijn vraag:

Hoe conventeert men de (gegeven)frequentie van een noot naar de periode van de bijbehorende PWM cycle?

thx all u,
MJ

In PWM we have high an lo rirght?

So how long would the period be?

How does this relates to a given frequency?

vergeten

Golden Member

Op 22 mei 2020 11:20:24 schreef Macaroni:
ben nieuw hier ;)

Ja dat is te merken lees eens dit de FAQ je bent nu aan het reageren op jezelf :)
Enne er is een editknop voor als je een eerder geplaats bericht wilt aanpassen!

Beetje geduld hebben wordt ook op prijs gesteld!
CircuitsOnline is een NL forum, in 2 talen posten is ook overbodig.

Doorgaans schrijf ik duidelijk wat ik bedoel, toch wordt het wel anders begrepen.

int buzzPin = 2;
int arrayLength;
float interval;
float noteLength = 1000; // 500 = 1/2, 250 = 1/4, etc
float pause1 = 0; // pause after each note
float pause2 = 62; // pause when rest (0)

int i;
int j;

// acceptable range: 5000 (low) - 100 (high)
int const c4 = 1880; // 261.63 Hz
int const db4 = 1775; // 277.18 Hz
int const d4 = 1675; // 293.66 Hz
int const eb4 = 1590; // 311.13 Hz
int const e4 = 1500; // 329.63 Hz
int const f4 = 1410; // 349.23 Hz
int const gb4 = 1340; // 369.99 Hz
int const g4 = 1260;// 392 Hz
int const ab4 = 1190; // 415.30 Hz
int const a4 = 1125; // 440 Hz
int const bb4 = 1065; // 466.16
int const b4 = 1000; // 493.88 Hz
int const c5 = 950; // 523.25 Hz
int const db5 = 895; // 554.37
int const d5 = 840; // 587.33 Hz
int const eb5 = 800; // 622.25
int const e5 = 750; // 659.25 Hz
int const f5 = 705; // 698.46
int const gb5 = 665; // 739.99
int const g5 = 630; // 783.99
int const ab5 = 600; // 830.61
int const a5 = 560; // 880.00 Hz
int const bb5 = 525; // 932.33 Hz
int const b5 = 495; // 987.77 Hz
int const c6 = 465; // 1046.50 Hz

int myNotes [] = {c4, db4, d4, eb4, e4, f4, gb4, g4, ab4, a4, bb4, b4,
c5, db5, d5, eb5, e5, f5, gb5, g5, ab5, a5, bb5, b5,
c6};
//int myNotes [] = {a4, b4, c5, d5, e5, f5, g5, 0};
//int myNotes [] = {a4, a4, a4, g4, g4, g4, f4, f4, f4, f4, f4, f4};

int playNote() {
interval = (noteLength) / (0.002 * myNotes);
for (j = 0; j <= interval; j++) {
digitalWrite(buzzPin, HIGH);
delayMicroseconds(myNotes );
digitalWrite(buzzPin, LOW);
delayMicroseconds(myNotes);
}
}

void setup() {
pinMode(buzzPin, OUTPUT);
arrayLength = sizeof(myNotes) / sizeof(int);
}

void loop() {
for (i = 8; i < 9; i++) {
if (myNotes) {
playNote();
}
else {
delay(pause2);
}
delay(pause1);
}
}

Laten we eens normaal doen met elkaar, ok?

Arco

Special Member

Als jij daar nou eens mee begint, met normaal doen?... :)

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com

oops we have a MORON! now face it!

Hoe conventeert men de (gegeven)frequentie van een noot naar de periode van de bijbehorende PWM cycle?

Arco

Special Member

Ik zie in mijn kristallen bol dat er een slotje aankomt... ;) (en wellicht wat verplichte tijd voor zelfreflectie)

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com

wow, da's ook alles wat jij zegt ;)

paaltje73

Golden Member

Niet te geloven zeg. Die pastaknager. Niemand die wat doet?

ik zeg slotje en ban. En zoek het uit met je PWM

Dit topic is gesloten