<commit_before>#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // twelve servo objects can be created on most boards
 
int pos = 90;    // variable to store the servo position 

//pinkers
int Lpinker = 4; // Linker pinker
int Rpinker = 2; // Rechter pinker

unsigned long previousMillis = 0;  // will store last time LED was updated
const long interval = 250; // interval at which to blink (milliseconds)
int RledState = LOW;
int LledState = LOW;

int hoekServo = 35;
int hoekServoRondkijken = 90;

#define echoPin A0 // Echo Pin
#define trigPin A1 // Trigger Pin
#define timeOutPin A5

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

unsigned long previousMillisServo = 0;  // will store last time LED was updated
const long intervalServo = 1000; // interval at which to blink (milliseconds)
unsigned long previousMillisSensor =0;
const long intervalSensor = 300;
 
bool vooruitRijden = LOW;
bool achteruitRijden= LOW;
bool linksRijden = LOW;
bool rechtsRijden = LOW;
bool rondKijken = LOW;
bool vooruitKijken = HIGH;

int LmotorA= 5;  // Left  motor H bridge, input A
int LmotorB = 6;  // Left  motor H bridge, input B
int RmotorA =9;  // Right motor H bridge, input A
int RmotorB =10;  // Right motor H bridge, input B

//int RCleft = 12;  // Digital input 10
//int RCright = 10;  // Digital input 12

int linksemodus=1;                                             // 0=achterwaards, 1=rem, 2=voorwaards.
int rechtsemodus=1;                                            // 0=achterwaards, 1=rem, 2=voorwaards.

int Mix = 1;     // Set to 1 if L/R and F/R signals from RC need to be mixed
int Leftcenter  = 1500;     // when RC inputs are centered then input should be 1.5mS
int Rightcenter = 1500; // when RC inputs are centered then input should be 1.5mS
int RCdeadband = 35;     // inputs do not have to be perfectly centered to stop motors

int linksePWM;                                                 // PWM waarde voor de linkse motor snelheid/rem.
int rechtsePWM;                                                // PWM waarde voor de rechtse motor snelheid/rem.

int LinkseSnelheid=0;
int RechtseSnelheid=0;
int Snelheid = 1500;
int Stuur = 1500;

int scale=12;  

unsigned long linkseoverbelasting;
unsigned long rechtseoverbelasting;

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   7
#define CSN_PIN 8

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

/*-----( Declare Variables )-----*/
int input[3];
int done;


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


  pinMode(LmotorA,OUTPUT);
  pinMode(RmotorA,OUTPUT);
  pinMode(LmotorB,OUTPUT);
  pinMode(RmotorB,OUTPUT);

  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
  
  myservo.attach(3);  // attaches the servo on pin 9 to the servo object 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(timeOutPin, OUTPUT);
  

}

void loop() {
   Snelheid = 1500;
   Stuur = 1500;
   unsigned long currentMillis = millis();
   unsigned long currentMillisServo = millis();
   unsigned long currentMillisSensor = millis();
  
  if (radio.available() )
  {
    vooruitRijden = LOW;
    Serial.println("Het werkt");
      
    // Fetch the data payload
      
      done = radio.read(input, sizeof(input));
      
      Serial.print("Switch:  ");
      Serial.print(input[0]);
      
      Snelheid= (input[1])+1000;
      
      Serial.print(input[1]);
      Serial.print("\n");
      Serial.print("Y-axis: ");
      Serial.println(input[2]);
      Stuur  = (input[2])+1000;
      Serial.print("\n\n"); 
    }
    else {
      if(currentMillisServo - previousMillisServo >= intervalServo) {
       
       previousMillisServo = currentMillisServo;     
       myservo.write(pos);  
       
       if(vooruitKijken){
       pos += hoekServo;
       if(pos >= 125 || pos<= 55)hoekServo = hoekServo*-1;
       }
       
       }
     }
   if (currentMillisSensor - previousMillisSensor >= intervalSensor) {
     previousMillisSensor = currentMillisSensor; 
     Distance(); 
     
     if (pos >= 55 && pos <= 125 && distance <= 10 && distance > 0) {        
       vooruitRijden = LOW;
       //rondKijken = HIGH;
       //vooruitKijken = LOW;
       Serial.println("STOP");
      }
       
     else if (pos >= 55 && pos <= 125 && distance > 10 || distance == -1) {

       vooruitRijden = HIGH;
       //rondKijken = LOW;
       Serial.println("DRIVE");
     }
     }
    
  
  if(vooruitRijden){
         Snelheid = 2000;
         Stuur = 1500;
  }
  
  if(rondKijken) {
    pos += hoekServoRondkijken;
       if(pos >= 180 || pos<= 0)hoekServoRondkijken = hoekServoRondkijken*-1;
       //if (pos == 90 && distance > 10 || distance == -1) vooruitKijken = HIGH;
       //if (pos == 0 && distance > 10 || distance == -1) { Stuur = 2000; Snelheid = 1500;}
    }<commit_msg>Kan half rechtsdraaien. RF werkt niet.<commit_after>#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // twelve servo objects can be created on most boards
 
int pos = 90;    // variable to store the servo position 
int count = 0;

//pinkers
int Lpinker = 4; // Linker pinker
int Rpinker = 2; // Rechter pinker

unsigned long previousMillis = 0;  // will store last time LED was updated
const long interval = 250; // interval at which to blink (milliseconds)
int RledState = LOW;
int LledState = LOW;

int hoekServo = 35;
int hoekServoRondkijken = 90;

#define echoPin A0 // Echo Pin
#define trigPin A1 // Trigger Pin
#define timeOutPin A5

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

unsigned long previousMillisServo = 0;  // will store last time LED was updated
const long intervalServo = 1000; // interval at which to blink (milliseconds)
unsigned long previousMillisSensor =0;
const long intervalSensor = 300;
 
bool vooruitRijden = LOW;
bool achteruitRijden= LOW;
bool linksRijden = LOW;
bool rechtsRijden = LOW;
bool rechtsKijken = LOW;
bool vooruitKijken = HIGH;
bool rechtsDraaien = LOW;

int LmotorA= 5;  // Left  motor H bridge, input A
int LmotorB = 6;  // Left  motor H bridge, input B
int RmotorA =9;  // Right motor H bridge, input A
int RmotorB =10;  // Right motor H bridge, input B

//int RCleft = 12;  // Digital input 10
//int RCright = 10;  // Digital input 12

int linksemodus=1;                                             // 0=achterwaards, 1=rem, 2=voorwaards.
int rechtsemodus=1;                                            // 0=achterwaards, 1=rem, 2=voorwaards.

int Mix = 1;     // Set to 1 if L/R and F/R signals from RC need to be mixed
int Leftcenter  = 1500;     // when RC inputs are centered then input should be 1.5mS
int Rightcenter = 1500; // when RC inputs are centered then input should be 1.5mS
int RCdeadband = 35;     // inputs do not have to be perfectly centered to stop motors

int linksePWM;                                                 // PWM waarde voor de linkse motor snelheid/rem.
int rechtsePWM;                                                // PWM waarde voor de rechtse motor snelheid/rem.

int LinkseSnelheid=0;
int RechtseSnelheid=0;
int Snelheid = 1500;
int Stuur = 1500;

int scale=12;  

unsigned long linkseoverbelasting;
unsigned long rechtseoverbelasting;

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   7
#define CSN_PIN 8

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

/*-----( Declare Variables )-----*/
int input[3];
int done;


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


  pinMode(LmotorA,OUTPUT);
  pinMode(RmotorA,OUTPUT);
  pinMode(LmotorB,OUTPUT);
  pinMode(RmotorB,OUTPUT);

  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
  
  myservo.attach(3);  // attaches the servo on pin 9 to the servo object 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(timeOutPin, OUTPUT);
  

}

void loop() {
   Snelheid = 1500;
   Stuur = 1500;
   unsigned long currentMillis = millis();
   unsigned long currentMillisServo = millis();
   unsigned long currentMillisSensor = millis();
  
  if (radio.available() )
  {
    vooruitRijden = LOW;
    Serial.println("Het werkt");
      
    // Fetch the data payload
      
      done = radio.read(input, sizeof(input));
      
      Serial.print("Switch:  ");
      Serial.print(input[0]);
      
      Snelheid= (input[1])+1000;
      
      Serial.print(input[1]);
      Serial.print("\n");
      Serial.print("Y-axis: ");
      Serial.println(input[2]);
      Stuur  = (input[2])+1000;
      Serial.print("\n\n"); 
    }
    else {
      if(currentMillisServo - previousMillisServo >= intervalServo) {
       
       previousMillisServo = currentMillisServo;     
       myservo.write(pos);  
       
       if(vooruitKijken)
       {         
         pos += hoekServo;
         if(pos >= 125 || pos <= 55) hoekServo = hoekServo*-1;
       }       
     }
     
   if (currentMillisSensor - previousMillisSensor >= intervalSensor) {
     previousMillisSensor = currentMillisSensor; 
     Distance(); 
     
     if (pos >= 55 && pos <= 125 && distance <= 10 && distance > 0) {
       count += 1;       
       vooruitRijden = LOW;       
       if (count >= 5) rechtsKijken = HIGH;
       
       Serial.println("STOP");
       
      }
       
     else if (pos >= 55 && pos <= 125 && distance > 10 || distance == -1) {
        count = 0;
       vooruitRijden = HIGH;
       //rondKijken = LOW;
       Serial.println("DRIVE");
     }
     }
     }
    
  
  if(vooruitRijden){
         Snelheid = 2000;
         Stuur = 1500;
  }
  
  if(rechtsKijken) {
    vooruitKijken = LOW;
    Serial.println("rechtskijken");
    Serial.println(distance);
    Serial.println(pos);
    pos = 0;
     if ( pos == 0 && distance >= 10 || distance == -1)
     {
       Snelheid = 1500;
       Stuur = 2000; 
       rechtsDraaien = HIGH;
       
       Serial.println("rechtsdraaien"); 
      //  vooruitKijken = HIGH;     
     }   
    /* else 
     {
       pos = 180;
       Serial.println("Linkskijken");
       
       if (pos == 180 && distance >= 20 ||distance == -1)
       {
         Snelheid = 1500;
         Stuur = 1000;
         Serial.println("Linksdraaien");
         vooruitKijken = HIGH;
       }       
       else vooruitKijken = HIGH;
     }*/
  }
  
  if (rechtsDraaien) 
  {
    pos = 90;
    Serial.println("Rechtsdraaien");
    if (pos == 90 && distance >= 30 || distance == -1)
    {
      rechtsKijken = LOW;
      vooruitKijken = HIGH;
    }
  }
{'fraction_non_alphanumeric': 0.11540196697645042, 'fraction_numerical': 0.033474690968149416, 'mean_word_length': 2.263839811542992, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6154218', 'n_tokens_mistral': 3987, 'n_tokens_neox': 3660, 'n_words': 1070}