Closed ahmdshrf closed 6 years ago
int melody[] = { NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4 };
int noteDurations[] = { 4, 8, 8, 4, 4, 4, 4, 4 };
void setup() {
for (int thisNote = 0; thisNote < 8; thisNote++) {
. int noteDuration = 1000 / noteDurations[thisNote]; tone(8, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
} }
void loop() {
}
//arduino is using in this prob
// notes in the melody: int melody[] = { NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4 };
// note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 8, 8, 4, 4, 4, 4, 4 };
void setup() { // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 8; thisNote++) {
int noteDuration = 1000 / noteDurations[thisNote];
tone(8, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
} }
void loop() { // no need to repeat the melody. }
//avr code for this problem
define F_CPU 16000000
include <avr/io.h>
include <util/delay.h>
include <avr/interrupt.h>
void hi(int t) { int i=1; for(i=1;i<=t;i++) { _delay_ms(40); } return 0; }
int main (void){ DDRC=0x03; DDRA=0x00; PORTA=0b11111111; int x,y;
}