Pages: 1 [2]   Go Down
Author Topic: Melodien Soundsequenzen mit dem arduino wieder geben  (Read 2167 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so da ich mit dem PROGMEM nicht weiter komm ( leuft net ) kam ich auf die idee die daten auf einer sd karte zu speichern so kan ich diese auch wariiren ? was wird dafür benötigt ?
Logged

Offline Offline
Edison Member
*
Karma: 21
Posts: 1419
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wo klemmt es denn bei Zugriff auf die PROGMEM Daten? Code? Fehlermeldungen?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also der folgende Code läuft einwandfrei und begrüßt dich sogar! ...  smiley-mr-green Die Ausgabe erfolgt über Pin 11, Pin 10 dient mir nur als Masse, weil ich gerade nur einen Speaker mit 2-Pin-Stecker zu Hand habe ...

Code:

PROGMEM byte snd[] ={128,129,129,129,129,128,125,125,128,128,129,131,130,
127,127,125,124,128,132,131,129,128,126,127,131,129,125,126,129,129,130,130,129,127,128,127,125,127,129,130,129,128,127,128,
129,128,127,127,129,129,129,126,124,125,128,130,132,132,129,128,127,123,121,124,128,132,135,134,129,124,122,122,126,132,133,
131,129,126,124,125,128,131,132,130,126,124,126,128,130,129,126,124,126,128,130,130,130,129,128,126,125,126,126,129,132,130,
128,126,123,124,130,133,132,129,126,125,126,127,127,127,127,130,133,132,127,123,122,125,130,132,132,132,132,129,126,123,124,
129,131,130,126,125,130,134,133,128,125,126,131,132,128,125,125,128,131,132,130,128,129,130,130,131,130,128,128,129,128,127,
127,128,128,131,128,125,125,128,129,129,127,122,121,122,122,125,126,125,127,128,124,122,124,125,129,130,122,119,122,126,130,
133,129,126,131,132,130,133,133,130,133,136,134,133,136,137,140,143,139,136,138,141,139,138,137,134,135,136,132,129,127,125,
124,123,121,120,121,119,113,109,107,109,113,110,105,103,107,111,114,113,109,111,127,141,141,136,125,119,122,128,128,128,131,
132,136,140,140,138,142,145,145,149,152,150,148,144,140,140,145,146,148,148,147,145,142,136,130,127,125,125,124,120,114,110,
105,102,99,94,94,97,97,97,97,106,126,143,147,139,126,115,114,118,121,123,126,129,134,139,137,132,129,130,132,132,131,
129,129,133,137,139,139,141,143,147,153,156,153,148,143,140,141,144,145,145,145,145,144,140,132,126,124,122,119,113,106,100,
95,91,88,89,91,91,92,98,116,145,164,159,136,114,104,107,115,117,117,120,132,144,148,143,133,126,127,130,129,127,127,
129,133,137,136,134,137,141,147,150,152,154,154,150,146,142,141,144,146,146,145,145,143,138,131,124,119,114,109,104,102,98,
92,86,82,82,84,87,97,127,160,169,158,137,114,106,110,109,105,108,117,131,149,153,145,139,136,134,131,125,118,118,128,
138,140,139,136,133,137,143,144,146,149,152,153,152,150,146,144,144,144,145,147,145,142,138,133,127,121,114,106,99,95,95,
98,92,87,86,83,84,90,113,151,170,163,143,126,118,120,115,101,95,105,121,140,149,145,141,147,155,152,135,115,106,112,
123,128,127,128,136,147,154,153,149,146,147,150,149,144,143,145,148,148,147,145,146,146,143,138,132,125,116,107,99,93,94,
97,94,89,88,87,87,89,88,111,155,171,161,146,130,124,131,120,97,88,98,113,133,141,136,146,166,172,159,138,115,108,
114,112,105,107,118,135,154,162,161,162,164,160,153,142,131,132,138,140,143,147,151,155,155,148,140,133,127,118,107,95,90,
93,95,91,87,86,88,90,87,83,108,151,161,156,148,139,142,149,133,107,97,97,104,115,115,111,129,155,169,169,159,144,
142,143,128,109,99,97,105,116,121,126,144,165,179,183,177,167,162,157,144,132,125,125,129,135,134,136,140,141,139,133,122,
113,106,96,88,81,72,67,67,70,70,87,130,156,160,164,163,163,173,162,131,111,102,93,92,89,79,93,122,145,159,166,
166,170,177,167,143,126,112,105,102,94,88,98,123,144,161,172,179,187,192,183,168,155,144,137,130,121,114,115,118,119,120,
119,117,118,118,113,105,97,85,74,68,62,61,89,120,130,137,150,158,175,183,165,146,140,128,117,105,86,77,92,108,118,
126,135,146,164,173,165,154,150,144,138,128,111,103,109,118,125,131,139,151,165,173,172,171,170,168,162,151,140,132,127,119,
112,106,103,102,102,99,97,98,96,90,84,80,77,77,102,127,129,131,142,146,162,170,155,140,139,133,125,118,102,92,103,
114,118,122,126,132,146,155,151,144,145,144,143,139,127,119,125,130,132,135,137,142,154,159,159,161,163,163,163,156,148,144,
139,130,123,116,108,104,101,94,90,88,86,80,78,77,78,81,103,126,127,130,142,148,161,170,158,145,145,140,131,123,110,
99,104,112,113,113,116,120,132,144,143,140,144,148,149,150,142,134,134,135,132,130,131,132,139,144,147,151,157,160,162,162,
158,154,151,144,135,127,120,112,105,98,92,88,88,84,79,76,75,72,76,102,122,122,127,139,144,162,174,162,152,152,148,
142,137,120,103,106,113,110,109,107,107,118,133,133,131,136,141,148,156,152,143,143,145,142,139,136,131,135,142,140,141,146,
149,152,156,154,151,152,149,142,136,128,120,115,109,101,96,94,90,86,82,79,77,75,85,107,112,111,123,133,142,161,162,
156,154,159,155,153,145,130,118,123,122,114,109,105,102,111,122,120,119,125,131,139,147,145,140,143,149,150,149,145,140,143,
150,150,145,143,142,145,148,146,139,138,139,139,136,131,122,118,117,113,107,102,96,91,88,84,78,74,84,103,103,104,117,
121,131,154,156,149,153,158,156,159,155,141,129,132,130,122,117,113,103,109,118,115,113,117,119,122,135,140,137,138,145,146,
150,154,150,147,153,154,150,150,147,140,141,145,139,135,137,134,131,133,134,132,120,114,111,104,98,87,73,67,62,57,76,
109,110,113,131,143,157,181,185,166,155,159,149,139,131,107,86,92,105,99,96,104,108,123,152,163,156,153,159,159,161,160,
138,116,115,119,116,117,119,120,132,156,170,172,176,177,177,177,172,153,135,127,118,109,99,88,79,77,81,79,78,78,74,
76,80,88,125,152,156,158,160,162,164,173,157,129,108,98,95,94,96,89,85,104,125,142,153,159,160,163,172,170,159,143,
128,117,112,112,107,101,103,109,121,136,149,154,159,165,171,173,172,167,158,151,146,139,132,124,116,109,103,97,92,87,83,
79,79,80,82,87,99,115,130,147,154,158,161,166,166,162,156,143,128,119,113,106,100,96,91,92,101,114,122,131,138,145,
153,162,166,162,155,147,139,131,125,116,104,97,95,96,102,110,117,124,135,148,159,167,172,171,167,164,161,153,144,136,126,
121,120,119,120,120,123,125,128,128,124,117,111,106,101,96,89,85,84,91,106,122,131,137,142,148,156,164,166,159,147,137,
127,123,120,113,102,94,94,99,109,121,129,132,136,144,152,159,162,157,146,136,129,122,118,112,105,97,95,100,107,118,129,
137,143,152,162,167,170,169,162,152,146,140,133,128,123,118,115,118,122,127,132,136,136,135,133,126,119,111,103,94,85,80,
79,83,94,110,124,135,145,151,156,163,168,167,160,149,135,122,113,109,103,98,96,95,99,108,121,132,143,150,154,155,157,
157,153,147,138,125,113,105,101,98,99,102,104,109,117,127,138,151,161,165,167,166,162,156,151,144,135,128,121,116,115,117,
120,124,130,134,136,141,144,143,141,136,127,117,106,95,84,78,75,76,82,96,113,128,143,155,160,165,167,167,164,158,148,
133,120,108,98,93,93,95,98,105,112,121,132,144,153,160,163,161,155,149,140,131,122,114,107,100,96,96,98,105,114,123,
132,142,149,155,159,162,162,161,157,149,139,132,124,118,117,117,119,121,125,129,134,139,142,144,145,142,137,131,124,116,107,
99,91,83,79,78,83,96,113,131,147,159,163,164,163,160,157,153,147,137,125,112,99,91,89,92,99,110,120,127,134,140,
146,151,157,160,159,154,144,131,118,109,103,100,101,104,106,110,113,119,127,137,147,155,160,160,155,149,142,135,132,129,126,
124,121,119,118,120,123,130,137,143,148,149,148,147,143,139,135,131,125,119,112,105,99,96,94,94,97,99,102,108,117,129,
142,153,161,163,161,154,145,136,129,123,118,115,111,108,104,103,104,109,118,128,138,147,151,152,149,145,140,136,133,129,125,
120,114,109,105,104,107,113,121,130,137,142,145,145,145,144,142,140,139,135,130,124,119,115,113,116,120,128,135,141,145,147,
147,146,145,144,143,141,139,134,130,125,120,117,115,113,113,112,113,112,112,112,112,112,112,114,118,123,131,138,144,147,147,
144,139,134,129,125,123,122,121,120,119,117,116,116,118,121,127,133,138,141,142,141,138,134,130,127,125,124,123,122,121,119,
118,117,118,121,126,131,136,140,141,141,139,137,134,131,128,127,126,124,123,121,120,120,121,125,130,137,143,148,150,149,147,
143,139,135,132,130,129,128,126,126,123,122,121,121,122,121,121,120,118,116,114,112,110,110,111,115,120,128,135,141,145,146,
145,141,137,132,127,125,123,121,120,119,117,116,115,116,119,124,130,136,141,143,144,142,138,134,129,125,123,121,120,119,119,
118,119,119,121,124,129,134,138,141,143,142,139,136,131,127,123,121,119,119,119,120,120,121,123,125,128,132,136,140,144,146,
147,147,144,141,137,132,129,126,124,124,124,125,127,129,131,132,132,133,132,130,128,124,120,116,112,109,106,105,105,106,110,
116,123,132,140,147,151,152,150,145,139,131,125,119,116,114,114,114,114,116,117,120,124,129,135,141,145,147,147,144,139,132,
126,121,116,114,113,114,116,119,122,125,127,130,133,136,139,142,142,142,139,134,129,124,119,116,115,115,117,120,124,127,130,
133,135,136,137,138,139,138,138,138,136,134,133,130,129,128,127,127,128,129,130,132,134,135,135,135,134,133,131,129,126,123,
119,115,112,110,108,108,108,109,111,114,119,125,133,140,146,150,150,148,143,136,127,121,115,112,112,113,116,118,121,123,126,
129,132,135,139,142,143,143,141,136,130,124,118,114,112,112,115,119,123,127};

#define PWM_Pin 11
#define GND_Pin 10

//---------------------------- setup ---------------------
void setup()
{
  int pwm_freq=1;
  TCCR2B = (TCCR2B & 0xF8) | pwm_freq;
  pinMode(PWM_Pin, OUTPUT);
  pinMode(GND_Pin, OUTPUT);
  digitalWrite(GND_Pin, LOW);
}
//---------------------------- loop ----------------------
void loop()
{ byte b;
  for (int i=0; i<sizeof(snd); i++)
  {
     b = pgm_read_byte(&snd[i]);
     analogWrite(PWM_Pin,b);
     delayMicroseconds(120);
  }
delay(2000);
}
« Last Edit: January 02, 2013, 03:03:01 pm by qualidat » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Was ist los, Sprache verschlagen?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

tut mir leid das ich mich jetzt erst wieder melde war verhindert mittlerweile läuft es =)
bin jetzt fleißig am schneiden von den sounddaten
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So nun läuft mal die Wiedergabe ganz gut nun hab ich ein neues Problem da ich den arduino in ein RC Truck baue und auch per Empfänger Gesteuert werden soll
ich habe in das Programm ein "pulseIn" eingebaut um das PWM des Empfängers auszulesen wie ich es schon oft gemacht hatte doch anscheinend verlangsamt das den Prozessor so sehr das nur ein gekratzte rauskommt und kein anständiger ton mehr.
habt ihr eine idee wie ich das mache das es geht ?
Logged

Pages: 1 [2]   Go Up
Jump to: