Hallo,
ich habe mich ein bisschen versucht aus dem passiven buzzer und knöpfen ein mini-Klavier zu machen.
Der Sketch kompiliert richtig aber bei dem Upload kommt es nicht durch, da hakt es irgendwie.Da kommt dann nichts mehr, egal wie lange ich warte. Habe anderweitig auch nichts zu dem Thema gefunden.
Benutze Windows 7, Arduino UNO R3(Atmel 328P) und die IDE ist auf 1.8.5
LG
#include "pitches.h"
int buttonApin = 1;
int buttonBpin = 2;
int buttonCpin = 3;
int buttonDpin = 4;
int buttonEpin = 5;
int buttonFpin = 8;
int buttonGpin = 9;
int buttonHpin = 10;
int buttonIpin = 11;
int buttonJpin = 12;
int noteC = NOTE_C5;
int noteD = NOTE_D5;
int noteE = NOTE_E5;
int noteF = NOTE_F5;
int noteG = NOTE_G5;
int noteA = NOTE_A5;
int noteH = NOTE_B5;
int noteCC = NOTE_C6;
int noteDD = NOTE_D6;
int noteEE = NOTE_E6;
int duration = 100;
void setup()
{
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
pinMode(buttonCpin, INPUT_PULLUP);
pinMode(buttonDpin, INPUT_PULLUP);
pinMode(buttonEpin, INPUT_PULLUP);
pinMode(buttonFpin, INPUT_PULLUP);
pinMode(buttonGpin, INPUT_PULLUP);
pinMode(buttonHpin, INPUT_PULLUP);
pinMode(buttonIpin, INPUT_PULLUP);
pinMode(buttonJpin, INPUT_PULLUP);
}
void loop()
{
if (digitalRead(buttonApin) == LOW)
{
tone(7,noteC, duration);
}
if (digitalRead(buttonBpin) == LOW)
{
tone(7,noteD, duration);
}
if (digitalRead(buttonCpin) == LOW)
{
tone(7,noteE, duration);
}
if (digitalRead(buttonDpin) == LOW)
{
tone(7,noteF, duration);
}
if (digitalRead(buttonEpin) == LOW)
{
tone(7,noteG, duration);
}
if (digitalRead(buttonFpin) == LOW)
{
tone(7,noteA, duration);
}
if (digitalRead(buttonGpin) == LOW)
{
tone(7,noteH, duration);
}
if (digitalRead(buttonHpin) == LOW)
{
tone(7,noteCC, duration);
}
if (digitalRead(buttonIpin) == LOW)
{
tone(7,noteDD, duration);
}
if (digitalRead(buttonJpin) == LOW)
{
tone(7,noteEE, duration);
}
}