int tempo = 1000; int tempoPotPin = A17; //int synthNotes[8] = { 60, 62, 64, 65, 67, 69, 71, 72 }; //int drumNotes[8] = { 36, 39, 36, 39, 36, 39, 36, 39 }; int kickNotes[8] = {1, 0, 0, 0, 1, 0, 0, 0}; int clapNotes[8] = {0, 1, 0, 1, 0, 1, 0, 1}; int openhihatNotes[8] = {0, 0, 1, 0, 0, 1, 0, 0}; int closedhihatNotes[8] = {0, 0, 0, 1, 0, 0, 0, 1}; int snareNotes[8] = {0, 0, 0, 0, 1, 0, 0, 0}; int cowbellNotes[8] = {1, 0, 0, 0, 0, 1, 0, 0}; int cymbalNotes[8] = {0, 0, 0, 1, 0, 0, 0, 1}; int tomNotes[8] = {0, 0, 1, 0, 0, 1, 0, 0};
//int NUM_CHANNELS = 4
int channelselectbutton ; int lastchannelselectbutton = LOW;
int velocity = 100;
int channel = 0;
// int channel = 2;
unsigned long lastStepTime = 0; int currentStep = 0; int totalSteps = 8;
int ledPins[8] = { 5, 6, 7, 8, 9, 10, 11, 12 }; int buttonStates[8] = { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW }; int lastButtonStates[8] = { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW };
//int lastButtonState = LOW; // state of the button last time you checked //#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); //make pin 2 an input: pinMode(25, INPUT); pinMode(26, INPUT); pinMode(27, INPUT); pinMode(28, INPUT); pinMode(29, INPUT); pinMode(30, INPUT); pinMode(31, INPUT); pinMode(32, INPUT);
pinMode (40, INPUT); // ON AND OFF BUTTON FOR INSTRUMENT SELECT
for (int i = 0; i < totalSteps; i++) { pinMode(ledPins[i], OUTPUT); } }
void loop() { updateTempo(); updateSequencer(); updateLeds(); updatebuttonChannelSelect(); // read the pushbutton: }
void updateTempo() { tempo = map(analogRead(A17), 0, 1023, 50, 1000); }
void updatebuttonChannelSelect() { channelselectbutton = digitalRead(40); if (channelselectbutton != lastchannelselectbutton) { if (channelselectbutton == LOW) { //channel++; channel = channel + 1; if (channel > 7) { // this channel will change to 7 eventually channel = 0; } Serial.print("channel "); Serial.println(channel); }
lastchannelselectbutton = channelselectbutton;
} }
// clap