<commit_before>


#define led1 2
#define led2 3
#define pot A2
#define hightimes 10 //time to keep led on in cycle
int logy = 5;
float freq = 250;

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(pot, INPUT);
  
}
void loop() {
  freq = analogRead(pot);  //between 4-32Hz blinks, 4 is 250ms, 32 is 31ms
  freq = map(freq, 100, 1024, 31, 250);
  freq = constrain(freq, 31,250);
  
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);   
  delay(hightimes); 
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  delay(freq-hightimes);
}<commit_msg>added tone to speaker on PB0<commit_after>/*
Note1: some code from the adafriut gemma simple thermain example.
Note2: The Arduino tone library does not work for the ATTiny85 on the
Trinket and Gemma.  The beep function below is similar.  The beep code
is adapted from Dr. <NAME> at
http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html
 */

#define SPEAKER   0    // Speaker on GPIO #0
#define SCALE     2.0  // You can change this to change the tone scale

#define led1 2
#define led2 1
#define pot A3
#define hightimes 10 //time to keep led on in cycle

int logy = 5;

void setup() {
  pinMode(SPEAKER,OUTPUT);
  
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(pot, INPUT);
  
}
void loop() {
  
  int input = analogRead(pot);  //between 4-32Hz blinks, 4 is 250ms, 32 is 31ms
  int freqLight = map(input, 100, 1024, 31, 250);
  freqLight = constrain(freqLight, 31,250);

  int freqAudio=220+(int)(input*SCALE); // change the voltage read to a frequency
                             // you can change the values to scale
                             // your frequency range  
  beep(SPEAKER,freqAudio,400);    // output the tone to digital pin 0
                             // you can change 400 to different times}

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);   
  delay(hightimes); 
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  delay(freqLight-hightimes);
}

 
// the sound producing function
void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)
{   // http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html
          int x;   
          long delayAmount = (long)(1000000/frequencyInHertz);
          long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
          for (x=0;x<loopTime;x++)   
          {  
              digitalWrite(speakerPin,HIGH);
              delayMicroseconds(delayAmount);
              digitalWrite(speakerPin,LOW);
              delayMicroseconds(delayAmount);
          }  
}
{'fraction_non_alphanumeric': 0.10921103769918383, 'fraction_numerical': 0.047804119704624955, 'mean_word_length': 2.824665676077266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4981946', 'n_tokens_mistral': 960, 'n_tokens_neox': 854, 'n_words': 260}