Newbie
Registriert seit: Dec 2009
Beiträge: 67
Bedankt: 20
|
Arduino uno programmierproblem
hallo
war am Wochenende auf einem Arduino Workshop und bin gerade dabei ein bisschen rumzuspielen mit dem ding bin auch noch ein ziemlicher anfänger in dem bereich habe vor "alle meine Entchen" über einen Lautsprecher abzuspielen das klappt auch soweit zusätzlich habe ich noch 7 LEDs auf meinem steckboard aufgebaut und ich möchte jetz jeder LED einen Ton zuordnen habe aber immer ein fehler beim Compiling
es wird mir keine Zeile markiert
hier das Programm:
Zitat:
#include "pitches.h"
// notes in the melody:
int melody[] = {
NOTE_C2, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_A3,
NOTE_A3, NOTE_A3, NOTE_G3, NOTE_A3, NOTE_A3, NOTE_A3, NOTE_A3, NOTE_G3,
NOTE_F3, NOTE_F3, NOTE_F3, NOTE_F3, NOTE_E3, NOTE_E3, NOTE_D3, NOTE_D3,
NOTE_D3, NOTE_D3, NOTE_C3};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 1, 4, 4, 4, 4, 1, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 1 };
void setup() {
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 27; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
if (melody[thisNote] == NOTE_C2) digitalWrite(2, HIGH);
if (melody[thisNote] == NOTE_D3) digitalWrite(3, HIGH);
if (melody[thisNote] == NOTE_E3) digitalWrite(4, HIGH);
if (melody[thisNote] == NOTE_F3) digitalWrite(5, HIGH);
if (melody[thisNote] == NOTE_G3) digitalWrite(6, HIGH);
if (melody[thisNote] == NOTE_A3) digitalWrite(7, HIGH);
if (melody[thisNote] == NOTE_C3) digitalWrite(8, HIGH);
// if (x > 120) digitalWrite(LEDpin, HIGH);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone( ;
}
}
void loop() {
// no need to repeat the melody.
}
|
ich weiß nicht was ich falsch mache ich würd mich über hilfe freuen
MFG GayFish
|