Search the Blog

Showing posts with label School Project. Show all posts
Showing posts with label School Project. Show all posts

Wednesday, August 14, 2019

Arduino Uno Code for lover robot


Arduino Uno Board Based project pof Lover Robot Code with Pin Digram and Details

Youtube Video for Demo

#include<Servo.h>
#define echoPin1 3
#define trigPin1 4
#define echoPin2 10
#define trigPin2 11
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
int amsl=5;
int amsr=6;
int amkl=7;
int amkr=8;
int head=9;
int aamsl;
int aamsr;
int aamkl;
int aamkr;
int ahead;
int Maximum=200;
int Minimum=0;
long duration1,distance1,duration2,distance2;

void setup()
{
  Serial.begin(9600);
  servo1.attach(amsl);
  servo2.attach(amsr);
  servo3.attach(amkl);
  servo4.attach(amkr);
  servo5.attach(head);
pinMode(trigPin1,OUTPUT);
pinMode(echoPin1,INPUT);
pinMode(trigPin2,OUTPUT);
pinMode(echoPin2,INPUT);
}


void loop()
{
  digitalWrite(trigPin1,LOW);
  digitalWrite(trigPin2,LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1,HIGH);
    digitalWrite(trigPin2,HIGH);
    delayMicroseconds(10);
      digitalWrite(trigPin1,LOW);
        digitalWrite(trigPin2,LOW);
        duration1=pulseIn(echoPin1,HIGH);
     
        duration2=pulseIn(echoPin2,HIGH);
        distance1=duration1/58.2;
        distance2=duration2/58.2;
 if((duration1<40)&&(duration2<40))
 {
  for(aamsl=0;aamsl<90;aamsl++)
  {
    servo1.write(aamsl);
    servo2.write(aamsl);
  delay(15);
  }

  for(aamsl=0;aamsl<90;aamsl++)
  {
    servo3.write(aamsl);
    servo4.write(aamsl);
  delay(15);
  }
  delay(10000);
  for(aamsl=90;aamsl>0;aamsl--)
  {
 
    servo3.write(aamsl);
    servo4.write(aamsl);
  delay(15);
  }
  for(aamsl=90;aamsl>0;aamsl--)
  {
 
    servo3.write(aamsl);
    servo4.write(aamsl);
  delay(15);
  }

 }

}

Arduino Uno board code for moving bridge with for rail road and river

Arduino Uno board code for moving bridge fro railway , Road, and River Project. This kind of project is generally used in all over the world and live running. So this is good project for Science and Engineeing Students, For Submitting the educational project.





#include <Servo.h>
Servo myservo;


int val,val2,val3;
int m; 

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
}

void loop()
{sawan:
  val = analogRead(A0);
  val2 = analogRead(A1);
  val3 = analogRead(A2);
 
  Serial.println(val);
   Serial.println(val2);
    Serial.println(val3);
    if((val>val2)&&(val>val3))
    {
      m=val;
      }
      else
      {

        if(val2>val3)
        m=val2;
        else
        m=val3;
        }
  int c=m/50;
  Serial.println(c);
  if(c>10&&c<12)
  {
    goto sawan;
    }
  else
  {
  switch(c)
  {
    case 1:
myservo.write(180);
delay(2000);
break;
    case 2:
myservo.write(180);
delay(2000);
break;

     case 3:
myservo.write(180);
delay(2000);
break;
    case 4:
myservo.write(180);
delay(2000);
break;
    case 5:
myservo.write(180);
delay(2000);
break;
   case 6:
myservo.write(180);
delay(2000);
break;
   case 7:
myservo.write(180);
delay(2000);
break;
   case 8:
myservo.write(180);
delay(2000);
break;
   case 9:
myservo.write(180);
delay(2000);
break;
   case 10:
myservo.write(90);
delay(2000);
break;
   case 11:
myservo.write(90);
delay(2000);
break;
   case 12:
myservo.write(90);
delay(2000);
break;
   case 13:
myservo.write(180);
delay(2000);
break;
   case 14:
myservo.write(180);
delay(2000);
break;
   case 15:
myservo.write(180);
delay(2000);
break;
   case 16:
myservo.write(180);
delay(2000);
break;
   case 17:
myservo.write(180);
delay(2000);
break;
   case 18:
myservo.write(180);
delay(2000);
break;
   case 19:
myservo.write(180);
delay(2000);
break;
   case 20:
myservo.write(180);
delay(2000);
break;
default :
myservo.write(90);
}
  }
}


Second Program For the Same Problem

#define motor 9
#define e1 7
#define e2 6
void setup()
{
  pinMode(8,INPUT);
  Serial.begin(9600);
  pinMode(motor,OUTPUT);
  pinMode(e1,OUTPUT);
  pinMode(e2,OUTPUT);
  }


  void loop()
  {   delay(1000);
    int sensor=digitalRead(8);
 
    Serial.println(sensor);
    if(sensor==1)
    {
          analogWrite(motor,1000);
          analogWrite(e1,0);
          analogWrite(e2,0);
    }
     else
       {
           for(int i=1;i<=10;i++)
               {
                   analogWrite(motor,1000);
                   analogWrite(e1,0);
                   analogWrite(e2,255);
                   delay(100);
              }
                   analogWrite(motor,0);
                   analogWrite(e1,0);
                   analogWrite(e2,0);
 
                   sawan();
       }
   
   
       delay(1000);
   
  }
void train()
    {

           for(int i=1;i<=17;i++)
               {
                   analogWrite(motor,1000);
                   analogWrite(e1,0);
                   analogWrite(e2,255);
                   delay(100);
              }
           analogWrite(motor,0);
           analogWrite(e1,0);
                   analogWrite(e2,0);
             vivek();
      }

void vivek()

{
  delay(10000);
         for(int i=1;i<=27;i++)
               {
                   analogWrite(motor,1000);
                   analogWrite(e1,255);
                   analogWrite(e2,0);
                   delay(100);
              }
           analogWrite(motor,0);
           analogWrite(e1,0);
                   analogWrite(e2,0);
               

  }
   void sawan()
         {
          int s=100;
          while(s<3000)
          {
            delay(100);
          int sensor=digitalRead(8);
          Serial.println(sensor);
          if(sensor==0)
          {
          train();
          }
          else
          {
          s=s+100;
          }
       
          delay(100);
          }
          delay(7000);
          for(int i=1;i<=10;i++)
               {
                   analogWrite(motor,1000);
                   analogWrite(e1,255);
                   analogWrite(e2,0);
                   delay(100);
              }
                   analogWrite(motor,0);
                   analogWrite(e1,0);
                   analogWrite(e2,0);
                   loop();
        }



Arduino Uno Code for E- Dustbin

E - Dustibin is the future of world, So every developing country is now finding the ways of collecting the garbage according to their category, like plastic garbage , metallic garbage, or biodegardable and not degradable items saparately.
So to have this thing in mind we have develop a science project of moving and auto open close and E- dustbin. Which will move at predefine path and collect the garbage and also automatically opens when user comes in near to that. 


#include <Servo.h>

Servo myservo;
int arr[9];

int punnu; 

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
  pinMode(8,INPUT);
   pinMode(10,INPUT);
    pinMode(11,INPUT);
}
int sawan()
{
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);
return sensorValue1+sensorValue2+sensorValue3/6;

  }
void loop()
{
  int sum=0;

  for(int i=0;i<9;i++)
    {
         arr[i]=sawan();
    }
     for(int i=0;i<9;i++)
      {
         sum=sum+arr[i];
         sum=sum/9;
         punnu=sum;
    }
 chauhan: 
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
    if((sensorValue1>punnu)||(sensorValue2>punnu)||(sensorValue3>punnu))
    {
      for (int pos = 0; pos <= 180; pos += 1)
      {
        myservo.write(180);           
        delay(500);                     
      }
    }
  else
   {
     for (int pos = 180; pos >= 0; pos -= 1)
     {
       myservo.write(pos);           
      delay(5000);                   
     }
   }
goto chauhan;
}

Translate