<commit_before>#define V 32
#define LED 5
#define POT 0 
#define GATEOUT 13

byte bpm = 120;
int stepTime; 
byte curStep = 0;
int playhead = 1;
byte dur[] = {50, 50, 50, 50};
byte numSteps = 4;

void setup(){
  stepTime = 60000.f / bpm;
  pinMode(LED, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop(){
  runSequence();
  delayMicroseconds(750); // in a genuine Arduino with a 16MHz crystal oscillator the delay should be 1ms
  // but on fake Arduinos with 12MHz oscillator the delay should be 0.75ms to have an accurrate clock running once every millisecond
}

void runSequence(){
  playhead++;
  if(playhead > numSteps * stepTime) playhead = 1; // reset playhead
  curStep = playhead / stepTime; // increment current step
  // Gate CV output 
 if(playhead % stepTime < stepTime * dur[curStep] / 100.f){
   digitalWrite(GATEOUT, HIGH);
   analogWrite(curStep+LED, 255-V);
 } 
 else{
   digitalWrite(GATEOUT, LOW);
   analogWrite(curStep+LED, 255-LOW);
 }
 
 dur[0] = analogRead(0) / 1024.f * 100;
}<commit_msg>added bpm control<commit_after>#define V 32
#define LED 5
#define POT 0 
#define GATEOUT 13

byte bpm = 120;
int stepTime; 
byte curStep = 0;
int playhead = 1;
byte dur[] = {50, 50, 50, 50};
byte numSteps = 4;

void setup(){
  pinMode(LED, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop(){
  runSequence();
  delayMicroseconds(750); // in a genuine Arduino with a 16MHz crystal oscillator the delay should be 1ms
  // but on fake Arduinos with 12MHz oscillator the delay should be 0.75ms to have an accurrate clock running once every millisecond
}

void runSequence(){
  playhead++;
  if(playhead > numSteps * stepTime) playhead = 1; // reset playhead
  curStep = playhead / stepTime; // increment current step
  // Gate CV output 
 if(playhead % stepTime < stepTime * dur[curStep] / 100.f){
   digitalWrite(GATEOUT, HIGH);
   analogWrite(curStep+LED, 255-V);
 } 
 else{
   digitalWrite(GATEOUT, LOW);
   analogWrite(curStep+LED, 255-LOW);
 }
 
 dur[0] = analogRead(0) / 1024.f * 100;
 bpm = (analogRead(8) >> 3) + 30; // from 30 to 157 bpm
 stepTime = 60000.f / bpm;

}
{'fraction_non_alphanumeric': 0.12090558766859345, 'fraction_numerical': 0.059248554913294796, 'mean_word_length': 3.688487584650113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3131076', 'n_tokens_mistral': 850, 'n_tokens_neox': 724, 'n_words': 245}