NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/*
* OTOKON ROBOTICS
* ARAZI KATEGORISI IZTECH
* ESEKARISI V1.9.1
*/

int ch1; // sag sol
int ch3; // ileri geri
int ch5; // reverse
float vehicle_speed = 0;
float vehicle_speed_reverse = 0;
float vehicle_direction = 0;
int reverse_state = 0;
float K = 1.2; //BU KATSAYIYI DEGISTIREREK TOPLAM HIZI ARTIRABILIRSIN

#define LeftBackIN1 2
#define LeftBackIN2 4
#define LeftBackEN 3

#define RightBackIN1 5
#define RightBackIN2 7
#define RightBackEN 6

#define LeftFrontIN1 8
#define LeftFrontIN2 9
#define LeftFrontEN 10

#define RightFrontIN1 12
#define RightFrontIN2 13
#define RightFrontEN 11




void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(LeftBackIN1, OUTPUT);
pinMode(LeftBackIN2, OUTPUT);
pinMode(LeftBackEN, OUTPUT);
pinMode(LeftFrontIN1, OUTPUT);
pinMode(LeftFrontIN2, OUTPUT);
pinMode(LeftFrontEN, OUTPUT);
pinMode(RightBackIN1, OUTPUT);
pinMode(RightBackIN2, OUTPUT);
pinMode(RightBackEN, OUTPUT);
pinMode(RightFrontIN1, OUTPUT);
pinMode(RightFrontIN2, OUTPUT);
pinMode(RightFrontEN, OUTPUT);
}

void loop() {
process();
float m = (vehicle_speed + vehicle_direction)*K;
float n = (vehicle_speed - vehicle_direction)*K;

if(m >= 255)
m = 255;
else if (m <= 0)
m = 0;
if(n >= 255)
n = 255;
else if (n <= 0)
n = 0;


if(reverse_state == 0){
if(vehicle_direction >= 118){
turnright(255,255);
}else if(vehicle_direction <= -118){
turnleft(255,255);
}else{
drive(m,n);
}
}
else if(reverse_state == 1){
if(vehicle_direction >= 118){
turnright(255,255);
}else if(vehicle_direction < -118){
turnleft(255,255);
}else{
drive_reverse(m,n);
}
}

}

void process (){
ch1 = pulseIn(A0, HIGH, 25000);
ch3 = pulseIn(A1, HIGH, 25000);
ch5 = pulseIn(A2, HIGH, 25000);

vehicle_direction = map(ch1, 1080,1907, -127, +127);
if(ch5 <= 1450){
reverse_state = 0;
vehicle_speed = map(ch3, 1076, 1906, 0, 255);
} else{
reverse_state = 1;
vehicle_speed = map(ch3, 1076, 1906, 0, 255);
}


}

void drive(float left, float right){
analogWrite(LeftFrontEN, left);
digitalWrite(LeftFrontIN1, HIGH); // ö o
digitalWrite(LeftFrontIN2, LOW); // o o

analogWrite(LeftBackEN, left);
digitalWrite(LeftBackIN1, HIGH); // o o
digitalWrite(LeftBackIN2, LOW); // ö o

analogWrite(RightFrontEN, right);
digitalWrite(RightFrontIN1, HIGH); // o ö
digitalWrite(RightFrontIN2, LOW); // o o

analogWrite(RightBackEN, right);
digitalWrite(RightBackIN1, HIGH); // o o
digitalWrite(RightBackIN2, LOW); // o ö

}

void drive_reverse(float left, float right){
analogWrite(LeftFrontEN, left);
digitalWrite(LeftFrontIN1, LOW); // ö o
digitalWrite(LeftFrontIN2, HIGH); // o o

analogWrite(LeftBackEN, left);
digitalWrite(LeftBackIN1, LOW); // o o
digitalWrite(LeftBackIN2, HIGH); // ö o

analogWrite(RightFrontEN, right);
digitalWrite(RightFrontIN1, LOW); // o ö
digitalWrite(RightFrontIN2, HIGH); // o o

analogWrite(RightBackEN, right);
digitalWrite(RightBackIN1, LOW); // o o
digitalWrite(RightBackIN2, HIGH); // o ö

}

void turnleft(float left, float right){
analogWrite(LeftFrontEN, left);
digitalWrite(LeftFrontIN1, LOW); // ö o
digitalWrite(LeftFrontIN2, HIGH); // o o

analogWrite(LeftBackEN, left);
digitalWrite(LeftBackIN1, LOW); // o o
digitalWrite(LeftBackIN2, HIGH); // ö o

analogWrite(RightFrontEN, right);
digitalWrite(RightFrontIN1, HIGH); // o ö
digitalWrite(RightFrontIN2, LOW); // o o

analogWrite(RightBackEN, right);
digitalWrite(RightBackIN1, HIGH); // o o
digitalWrite(RightBackIN2, LOW); // o ö
}

void turnright(float left, float right){
analogWrite(LeftFrontEN, left);
digitalWrite(LeftFrontIN1, HIGH); // ö o
digitalWrite(LeftFrontIN2, LOW); // o o

analogWrite(LeftBackEN, left);
digitalWrite(LeftBackIN1, HIGH); // o o
digitalWrite(LeftBackIN2, LOW); // ö o

analogWrite(RightFrontEN, right);
digitalWrite(RightFrontIN1, LOW); // o ö
digitalWrite(RightFrontIN2, HIGH); // o o

analogWrite(RightBackEN, right);
digitalWrite(RightBackIN1, LOW); // o o
digitalWrite(RightBackIN2, HIGH); // o ö
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.