int tempo = 1000;
int tempoPotPin = A17;
int note = 60;
int note1 = 62;
int note2 = 64;
int note3 = 65;
int note4 = 67;
int note5 = 69;
int note6 = 71;
int note7 = 72;
int velocity = 100;
int channel = 1;
// for sequencer
unsigned long lastStepTime = 0;
int currentStep = 0;
int totalSteps = 8;
int ledPins[8] = { 5, 6, 7, 8, 9, 10, 11, 12 };
//#include <MIDI.h>
//MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
void setup() {
//MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize MIDI with Omni channel (responds to all MIDI channels)
//usbMIDI.sendNoteOn(note, velocity, channel); // Replace 'note', 'velocity', and 'channel' with your values
Serial.begin(9600);
for (int i = 0; i < totalSteps; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
updateTempo();
updateSequencer();
updateLeds();
}
void updateTempo() {
tempo = map(analogRead(A17), 0, 1023, 50, 1000);
}
void updateSequencer() {
if (millis() > lastStepTime + tempo) {
lastStepTime = millis();
currentStep++;
if (currentStep >= totalSteps) {
currentStep = 0;
}
Serial.println(currentStep);
if (currentStep == 0) {
usbMIDI.sendNoteOn(note, velocity, channel);
}
if (currentStep == 1) {
usbMIDI.sendNoteOn(note1, velocity, channel);
}
if (currentStep == 2) {
usbMIDI.sendNoteOn(note2, velocity, channel);
}
if (currentStep == 3) {
usbMIDI.sendNoteOn(note3, velocity, channel);
}
if (currentStep == 4) {
usbMIDI.sendNoteOn(note4, velocity, channel);
}
if (currentStep == 5) {
usbMIDI.sendNoteOn(note5, velocity, channel);
}
if (currentStep == 6) {
usbMIDI.sendNoteOn(note6, velocity, channel);
}
if (currentStep == 7) {
usbMIDI.sendNoteOn(note7, velocity, channel);
}
}
}
void updateLeds() {
for (int i = 0; i < totalSteps; i++) {
if (currentStep == i) {
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
}
//usbMIDI.sendNoteOn(note, velocity, channel);
}
}