Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a pull for agrobot making through obstacle avoid bot #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

188 changes: 188 additions & 0 deletions 01. Codes/new.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
int pinML1=36;
int pinML2=35;
int pinMR1=12;
int pinMR2=11;


int LEDbackL=9;
int LEDbackR=7;
int LEDfrontL=3;
int LEDfrontR=2;
int LEDsideL=1;
int LEDsideR=13;

void setup()
{
// put your setup code here, to run once:

// For Motors
pinMode(pinML1,OUTPUT);
pinMode(pinML2,OUTPUT);
pinMode(pinMR1,OUTPUT);
pinMode(pinMR2,OUTPUT);
//For the purpose of output
pinMode(LEDbackL,OUTPUT);
pinMode(LEDbackR,OUTPUT);
pinMode(LEDfrontL,OUTPUT);
pinMode(LEDfrontR,OUTPUT);
pinMode(LEDsideL,OUTPUT);
pinMode(LEDsideR,OUTPUT);

}



void moveForward(int spd,int TotalTime,int BlinkTime)
{
analogWrite(pinML1,spd);
analogWrite(pinML2,HIGH);
analogWrite(pinMR1,spd);
analogWrite(pinMR2,HIGH);

int count=0;
while(true)
{

digitalWrite(LEDfrontL,HIGH);
digitalWrite(LEDfrontR,HIGH);
delay(BlinkTime);
count=count+BlinkTime;
digitalWrite(LEDfrontL,LOW);
digitalWrite(LEDfrontR,LOW);
delay(BlinkTime);
count=count+BlinkTime;

if(count>=TotalTime)
break;
}

}

void moveBackward(int spd,int TotalTime,int BlinkTime)
{
analogWrite(pinML1,LOW);
analogWrite(pinML2,spd);
analogWrite(pinMR1,LOW);
analogWrite(pinMR2,spd);

int count=0;
while(true)
{

digitalWrite(LEDbackL,HIGH);
digitalWrite(LEDbackR,HIGH);
delay(BlinkTime);
count=count+BlinkTime;
digitalWrite(LEDbackL,LOW);
digitalWrite(LEDbackR,LOW);
delay(BlinkTime);
count=count+BlinkTime;

if(count>=TotalTime)
break;
}

}

void turnLeft(int spd,int TotalTime,int BlinkTime)
{
analogWrite(pinML1,LOW);
analogWrite(pinML2,LOW);
analogWrite(pinMR1,spd);
analogWrite(pinMR2,LOW);

int count=0;
while(true)
{

digitalWrite(LEDfrontL,HIGH);
delay(BlinkTime);
count=count+BlinkTime;
digitalWrite(LEDfrontL,LOW);
delay(BlinkTime);
count=count+BlinkTime;

if(count>=TotalTime)
break;
}

}

void turnRight(int spd,int TotalTime,int BlinkTime)
{
analogWrite(pinML1,spd);
analogWrite(pinML2,LOW);
analogWrite(pinMR1,LOW);
analogWrite(pinMR2,LOW);

int count=0;
while(true)
{

digitalWrite(LEDfrontR,HIGH);
delay(BlinkTime);
count=count+BlinkTime;
digitalWrite(LEDfrontR,LOW);
delay(BlinkTime);
count=count+BlinkTime;

if(count>=TotalTime)
break;
}

}

void STOP()
{
analogWrite(pinML1,LOW);
analogWrite(pinML2,LOW);
analogWrite(pinMR1,LOW);
analogWrite(pinMR2,LOW);


digitalWrite(LEDbackL,HIGH);
digitalWrite(LEDbackR,HIGH);
digitalWrite(LEDfrontR,LOW);
digitalWrite(LEDfrontL,LOW);
digitalWrite(LEDsideL,LOW);
digitalWrite(LEDsideR,LOW);

}

void RESET()
{
//Reset LED pin
analogWrite(pinML1,LOW);
analogWrite(pinML2,LOW);
analogWrite(pinMR1,LOW);
analogWrite(pinMR2,LOW);
digitalWrite(LEDbackL,LOW);
digitalWrite(LEDbackR,LOW);
digitalWrite(LEDfrontL,LOW);
digitalWrite(LEDfrontR,LOW);
digitalWrite(LEDsideL,LOW);
digitalWrite(LEDsideR,LOW);

}


void loop()
{
// put your main code here, to run repeatedly:


/*
* RESET() & STOP() ----> parameterless.
* all other functions ----> (speed,TotalTime,BlinkTime)
*/

RESET();
digitalWrite(LEDsideL,LOW);
digitalWrite(LEDsideR,LOW);
moveForward(255,3000,300);
moveBackward(255,3000,300);
turnLeft(255,3000,300);
turnRight(255,3000,300);
STOP();
delay(5000);
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading