<commit_before>#include <MINDSi.h>
#include <Servo.h>

/***************************************************
/ Example provided by MINDS-i
/ Try checking out our arduino resource guide at
/ http://mindsieducation.com/programming-resources
/ Questions? Concerns? Bugs? email <EMAIL>
/
/ This example expects 2 servos in pins 4 and 5
/ and three QTI sensors in pins A0, A1, and A2
/***************************************************/

Servo leftServo, rightServo;
bool left, middle, right;

float Lout, Rout;
float Lset, Rset;

unsigned long time;
double dT;
double adj;

const int center = 90;

void setup() {
  Serial.begin(115200);

  leftServo.attach(5);
  rightServo.attach(4);

  leftServo.write(center);
  rightServo.write(center);

  Rout = center;
  Lout = center;
}

void loop() {
  left   = QTI(A0) > 120;
  middle = QTI(A1) > 120;
  right  = QTI(A2) > 120;

  if (left) {
    Lset = center + 6;
    Rset = center + 45;
  }
  else if (right) {
    Lset = center - 45;
    Rset = center - 6;
  }
  else if (middle) {
    Lset = center - 45;
    Rset = center + 45;
  }

  output();
}

void output() {
  //all this is because the QTI Blocks for a variable amount of time
#define rxtime .25

  dT = ( double(millis() - time) / 100) ;
  time = millis();

  adj = pow(rxtime, dT);

  Rout = ( Rout * adj ) + ( Rset * (1 - adj) );
  Lout = ( Lout * adj ) + ( Lset * (1 - adj) );

  leftServo.write(Lout);
  rightServo.write(Rout);
}
<commit_msg>Refactored and better paramaterized lineFollowBot_Line example<commit_after>#include <MINDSi.h>
#include <Servo.h>

/***************************************************
/ Example provided by MINDS-i
/ Try checking out our arduino resource guide at
/ http://mindsieducation.com/programming-resources
/ Questions? Concerns? Bugs? email <EMAIL>
/
/ This example expects 2 servos in pins 4 and 5
/ and three QTI sensors in pins A0, A1, and A2
/***************************************************/

Servo left, right;

float Lout, Rout;
float Lset, Rset;

const double rxtime    = 0.25;
const int neutral      = 90;
const int leftCenter   = 4;
const int rightCenter  = 5;
const int outsideSpeed = 45;
const int insideSpeed  = 12;
const int forwardSpeed = 35;

void setup() {
  Serial.begin(9600);

  left.attach(5);
  right.attach(4);

  left.write(neutral);
  right.write(neutral);

  Rout = neutral;
  Lout = neutral;
}

void loop() {
  bool left   = QTI(A0) > 120;
  bool middle = QTI(A1) > 120;
  bool right  = QTI(A2) > 120;

  if (left) {
    Lset = neutral + insideSpeed;
    Rset = neutral + outsideSpeed;
  }
  else if (right) {
    Lset = neutral - outsideSpeed;
    Rset = neutral - insideSpeed;
  }
  else if (middle) {
    Lset = neutral - forwardSpeed;
    Rset = neutral + forwardSpeed;
  }

  output();
}

//all this is because the QTI Blocks for a variable amount of time
void output() {
  static uint32_t time = millis();

  double dT = ( double(millis() - time) / 100) ;
  time = millis();

  double adj = pow(rxtime, dT);

  Rout = ( Rout * adj ) + ( Rset * (1 - adj) );
  Lout = ( Lout * adj ) + ( Lset * (1 - adj) );

  left.write(Lout + leftCenter);
  right.write(Rout+ rightCenter);
}

{'fraction_non_alphanumeric': 0.1875, 'fraction_numerical': 0.028236040609137057, 'mean_word_length': 3.204, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '255830', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1102, 'n_words': 338}