myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Programmierung
Seite neu laden

Arduino uno programmierproblem

Willkommen

myGully

Links

Forum

 
Antwort
 
Themen-Optionen Ansicht
Ungelesen 22.11.11, 11:21   #1
GayFish
Newbie
 
Benutzerbild von GayFish
 
Registriert seit: Dec 2009
Beiträge: 67
Bedankt: 20
GayFish ist noch neu hier! | 0 Respekt Punkte
Standard

hallo
ein bekannter hat mir geholfen wenns jemand interessiert hier ist das fehlerfreie programm
ich hatte die Pin declaration vergessen und noch ein paar andere kleine fehler gemacht
Zitat:
#include "pitches.h"

// notes in the melody:
int melody[] = {
NOTE_C3, 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() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
// 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_C3) {
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 (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);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
// stop the tone playing:
noTone(;
}
}

void loop() {
// no need to repeat the melody.
}
jetz wird alle meine entchen abgespielt und immer wenn ein anderer Ton kommt geht eine andere LED an natürlich schön in rheinfolge auf gebaut

MFG GayFish
GayFish ist offline   Mit Zitat antworten
Antwort


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:05 Uhr.


Sitemap

().