Search the Blog

Showing posts with label ROBOTICS. Show all posts
Showing posts with label ROBOTICS. Show all posts

Thursday, August 15, 2019

Arduino code ultrasonic sensor with processing code


Ultrasonic RADAR Demo Project

Ultrasonic Sensor:


An ultrasonic sensor is an instrument that measure the distance to an object using ultrasonic sound waves.
An ultrasonic sensor uses a transducer to send and receive ultrasonic pulses that relay back information about an object’s proximity.
High-frequency sound waves reflect from boundaries to produce distinct echo patterns and return in varoius direction
Arduino code ultrasonic sensor with processing code


Processing Application :

Processing is a flexible software sketchbook
application and a language for learning how
to code within the context of the visual arts.
Since the, Processing has promoted software
literacy within the visual arts and visual
literacy within technology. There are tens
of thousands of students, progrmmers, artists,
designers, researchers, and hobbyists who use
Processing for learning and prototyping.

Please Visit this for more Information
#define echoPin 7
#define trigPin 8
#define LEDPin 13
int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance via some mathmatical formuls

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

void loop() {
/* The following trigPin/ echoPin cycle is used to determine the
 distance of the nearest object  by bouncing the soundwaves off of it. */
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);

 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);

 //Calculate the distance (in cm) based on the speed of sound and time.
 distance = duration/58.2;

 if (distance >= maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON
 to indicate "out of range" */
 Serial.println("-1");
 digitalWrite(LEDPin, HIGH);
 }
 else {
 /* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(distance);
 digitalWrite(LEDPin, LOW);
 }

 //Delay 50ms before next reading.
 delay(50);
}

Arduino UNO Board



Please See- In this Project i use 5 Ultrsonic Sensor








Processing code Application Code :-



import processing.serial.*;


int numOfShapes = 60; // Number of squares to display on screen
int shapeSpeed = 2; // Speed at which the shapes move to new position
 // 2 = Fastest, Larger numbers are slower

//Global Variables
Square[] mySquares = new Square[numOfShapes];
int shapeSize, distance;
String comPortString;
Serial myPort;

/* -----------------------Setup ---------------------------*/
void setup(){
 size(displayWidth,displayHeight); //Use entire screen size.
 smooth(); // draws all shapes with smooth edges.

 /* Calculate the size of the squares and initialise the Squares array */
 shapeSize = (width/numOfShapes);
 for(int i = 0; i<numOfShapes; i++){
 mySquares[i]=new Square(int(shapeSize*i),height-40);
 }

 /*Open the serial port for communication with the Arduino
 Make sure the COM port is correct - I am using COM port 8 */
 myPort = new Serial(this, "COM8", 9600);
 myPort.bufferUntil('\n'); // Trigger a SerialEvent on new line
}

/* ------------------------Draw -----------------------------*/
void draw(){
 background(0); //Make the background BLACK
 delay(50); //Delay used to refresh screen
 drawSquares(); //Draw the pattern of squares
}


/* ---------------------serialEvent ---------------------------*/
void serialEvent(Serial cPort){
 comPortString = cPort.readStringUntil('\n');
 if(comPortString != null) {
 comPortString=trim(comPortString);

 /* Use the distance received by the Arduino to modify the y position
 of the first square (others will follow). Should match the
 code settings on the Arduino. In this case 200 is the maximum
 distance expected. The distance is then mapped to a value
 between 1 and the height of your screen */
 distance = int(map(Integer.parseInt(comPortString),1,200,1,height));
 if(distance<0){
 /*If computer receives a negative number (-1), then the
 sensor is reporting an "out of range" error. Convert all
 of these to a distance of 0. */
 distance = 0;
 }
 }
}
Arduino code ultrasonic sensor with processing code




/* ---------------------drawSquares ---------------------------*/
void drawSquares(){
 int oldY, newY, targetY, redVal, blueVal;

 /* Set the Y position of the 1st square based on
 sensor value received */
 mySquares[0].setY((height-shapeSize)-distance);

 /* Update the position and colour of each of the squares */
 for(int i = numOfShapes-1; i>0; i--){
 /* Use the previous square's position as a target */
 targetY=mySquares[i-1].getY();
 oldY=mySquares[i].getY();

 if(abs(oldY-targetY)<2){
 newY=targetY; //This helps to line them up
 }else{
 //calculate the new position of the square
 newY=oldY-((oldY-targetY)/shapeSpeed);
 }
 //Set the new position of the square
 mySquares[i].setY(newY);

 /*Calculate the colour of the square based on its
 position on the screen */
 blueVal = int(map(newY,0,height,0,255));
 redVal = 255-blueVal;
 fill(redVal,0,blueVal);

 /* Draw the square on the screen */
 rect(mySquares[i].getX(), mySquares[i].getY(),shapeSize,shapeSize);
 }
}

/* ---------------------sketchFullScreen---------------------------*/
// This puts processing into Full Screen Mode
boolean sketchFullScreen() {
 return true;
}

/* ---------------------CLASS: Square ---------------------------*/
class Square{
 int xPosition, yPosition;

 Square(int xPos, int yPos){
 xPosition = xPos;
 yPosition = yPos;
 }

 int getX(){
 return xPosition;
 }

 int getY(){
 return yPosition;
 }

 void setY(int yPos){
 yPosition = yPos;
 }
}

More than 20 aurduino Project

Arduino uno board Code of Pic and Place ROBOT

Pic And Place ROBOT is work like Automatic Creane System







#define m11 1
#define m12 0
#define m21 7
#define m22 6
#define m31 3
#define m32 2
#define m41 4
#define m42 5

#define D0 19
#define D1 18
#define D2 17
#define D3 16

void forward()
{
   digitalWrite(m11, LOW);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, LOW);
   digitalWrite(m22, HIGH);
   digitalWrite(m31, LOW);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, LOW);
   digitalWrite(m42, HIGH);
}

void backward()
{
   digitalWrite(m11, HIGH);
   digitalWrite(m12, LOW);
   digitalWrite(m21, HIGH);
   digitalWrite(m22, LOW);
   digitalWrite(m31, HIGH);
   digitalWrite(m32, LOW);
   digitalWrite(m41, HIGH);
   digitalWrite(m42, LOW);
}

void left()
{
   digitalWrite(m11, LOW);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, HIGH);
   digitalWrite(m22, HIGH);
   digitalWrite(m31, LOW);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, HIGH);
   digitalWrite(m42, HIGH);
}

void right()
{
   digitalWrite(m11, HIGH);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, LOW);
   digitalWrite(m22, HIGH);
    digitalWrite(m31, HIGH);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, LOW);
   digitalWrite(m42, HIGH);
}

void Stop()
{
   digitalWrite(m11, HIGH);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, HIGH);
   digitalWrite(m22, HIGH);
   digitalWrite(m31, HIGH);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, HIGH);
   digitalWrite(m42, HIGH);
}

void setup()
{
  pinMode(D0, INPUT);
  pinMode(D1, INPUT);
  pinMode(D2, INPUT);
  pinMode(D3, INPUT);

  pinMode(m11, OUTPUT);
  pinMode(m12, OUTPUT);
  pinMode(m21, OUTPUT);
  pinMode(m22, OUTPUT);
  pinMode(m31, OUTPUT);
  pinMode(m32, OUTPUT);
  pinMode(m41, OUTPUT);
  pinMode(m42, OUTPUT);
}

void loop()
{

  int temp1=digitalRead(D0);
  int temp2=digitalRead(D1);
  int temp3=digitalRead(D2);
  int temp4=digitalRead(D3);

  if(temp1==1 && temp2==0 && temp3==0 && temp4==0)
  forward();

  else if(temp1==0 && temp2==1 && temp3==0 && temp4==0)
  left();

  else if(temp1==1 && temp2==1 && temp3==0 && temp4==0)
  right();

  else if(temp1==0 && temp2==0 && temp3==1 && temp4==0)
  backward();

   else if(temp1==1 && temp2==0 && temp3==1 && temp4==0)
  Stop();
}

Arduino uno board complete code of ROBOT

Arduino Uno board Code for maze robot for path ROBOT

Arduino uno board complete code of ROBOT


#include<Servo.h>


Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

int amsr=9;
int amsl=7;
int amskr=10;
int amskl=8;




int aamsl;


void setup()
{


  servo2.attach(amsr);
  servo1.attach(amskr);
  servo3.attach(amsl);
  servo4.attach(amskl);

}


void loop()
{

 {
  for(aamsl=150;aamsl>30;aamsl--)
  {
    int ab=180-aamsl;
    servo2.write(aamsl);
    servo3.write(ab);
  delay(3);
  }
  delay(1000);
  for(int i=1;i<=3;i++)
  {
  for(aamsl=150;aamsl>60;aamsl--)
  {
    int fg=aamsl-50;
    servo1.write(aamsl);
    servo4.write(fg);
  delay(20);
  }
  delay(1000);
  for(aamsl=60;aamsl<150;aamsl++)
  {
    int fd=aamsl+50;
    servo1.write(aamsl);
    servo4.write(fd);
  delay(20);
  }
  }
  delay(1000);
  for(aamsl=30;aamsl<150;aamsl++)
  {
    int cd=180-aamsl;
    servo2.write(aamsl);
    servo3.write(cd);
  delay(20);
  }
  delay(1000);

 }
}


JAVA Triangle * Pattern Program Logic one Programming Logic and Code with Syntax

Arduino Uno board with servo test

Arduino Uno board with servo test with actual and tested example

Arduino Uno board with servo test with actual and tested example Varified

#include <Servo.h>

Servo myservo3;

Servo myservo5;

Servo myservo6;

int potpin = 0;
int potpin2 = 1;

int potpin3 = 2;

int val = 0;
int val2 = 0;

int val3 = 0;

void setup()
{

myservo3.attach(9);
myservo5.attach(10);

myservo6.attach(11);

}

void loop()
{

val = analogRead(potpin);
val = map(val, 3, 1023, 0, 176);

myservo3.write(val);

delay(25);

val2 = analogRead(potpin2);
val2 = map(val2, 3, 1023, 0, 176);

myservo5.write(val2);

delay(25);

val3 = analogRead(potpin3);
val3 = map(val3, 3, 1023, 0, 175);

myservo6.write(val3);

delay(25);

}


JAVA Sequence Pattern Program Programming Logic and Code with Syntax

Arduino uno board Code for Ultrasonic sensor with relay

Arduino UNO Board Code For Ultrsonic Sensor with Realy and LED Pin for High and LOW Demo

Arduino uno board Code for Ultrasonic sensor with relay and Demo Example

#define echoPin 7
#define trigPin 8
#define LEDPin 12
int relay1=2;
int relay2=3;
int relay3=4;
int relay4=5;
int i=1,s;
int a=10,b=10,c=10,d=10;
int maximumRange = 200;
int minimumRange = 0;
long duration, distance;

void setup()
{
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin,  INPUT);
 pinMode(relay1,  OUTPUT);
 pinMode(relay2,  OUTPUT);
 pinMode(relay3,  OUTPUT);
 pinMode(relay4, OUTPUT);
}

void loop()
{

 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);

 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = duration/58.2;
switch(i)
{
  case 1:
  {
    while(a<1000)
      {
        digitalWrite(relay4,LOW);
         digitalWrite(relay1,HIGH);
       
         while(distance<5)
         {
           digitalWrite(relay1,LOW);
           delay(1000);
           s=2;
           a=1000;
             break;
         }
         delay(100);
         a=a+100;
      }
      s=2;
      a=100;
      break;
  }
      case 2:
   { 
      while(b<1000)
      {
        digitalWrite(relay1,LOW);
         digitalWrite(relay2,HIGH);
         delay(100);
         while(distance<5)
         {
           digitalWrite(relay2,LOW);
           delay(1000);
           s=3;
           b=1000;
             break;
         }
        delay(100);
         b=b+100;
      }
      s=3;
      b=100;
      break;
   
   }
   case 3:
   { 
      while(c<1000)
      {
         digitalWrite(relay2,LOW);
         digitalWrite(relay3,HIGH);
       
         while(distance<5)
         {
           digitalWrite(relay3,LOW);
           delay(1000);
           s=4;
           c=1000;
             break;
         }
         delay(100);
         c=c+100;
      }
      s=4;
      c=100;
      break;
   }
   case 4:
 {   
      while(d<1000)
      {
        digitalWrite(relay3,LOW);
         digitalWrite(relay4,HIGH);
       
         while(distance<5)
         {
           digitalWrite(relay4,LOW);
           delay(1000);
           s=1;
           d=1000;
             break;
         }
         delay(100);
         d=d+100;
      }
      s=1;
      d=100;
      break;
 }
}
delay(1000);
i=s;
}


SQL Query for Purchase Order details Programming Logic and Code with Syntax





Arduino Code for ultrsonic RADAR

Micocontroller,  ROBOTICS,  Arduino Uno Board Project Example fro School and Science exibiation and College Projects.

Micocontroller,  ROBOTICS,  Arduino Uno Board Project Example fro School and Science exibiation.

#define echoPin 7
#define trigPin 8
#define LEDPin 13
int relay1=2;
int relay2=3;
int relay3=4;
int relay4=5;
int maximumRange = 200;
int minimumRange = 0;
long duration, distance;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin,  OUTPUT);
  pinMode(relay1,  OUTPUT);
   pinMode(relay2,  OUTPUT);
    pinMode(relay3,  OUTPUT);
     pinMode(relay4, OUTPUT);
}

void loop() {

 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);

 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);


 distance = duration/58.2;

 if (distance >25)

 {
   digitalWrite(relay1,HIGH);
   delay(5000);
   digitalWrite(relay1,LOW);
   digitalWrite(relay2,HIGH);
   delay(5000);
 
   digitalWrite(relay2,LOW);
   digitalWrite(relay3,HIGH);
   delay(5000);
 
   digitalWrite(relay3,LOW);
   digitalWrite(relay4,HIGH);
   delay(5000);
 
   digitalWrite(relay4,LOW);

   delay(5000);
 
 }

 delay(50);
}


JAVA Sequence Pattern Program with * pattern Programming Logic and Code with Syntax

Wednesday, August 14, 2019

Arduino uno board of servo motor

Servo Motor Rotation For Perticular length

Servo Motor Rotation For Perticular length and Stop

#include <Servo.h>

Servo myservo;


int pos = 0; 

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

void loop()
{
  int sensorValue = analogRead(A0);

Serial.println(sensorValue);
  if(sensorValue>850)
  {
    myservo.write(0); 
      delay(5000);                               
  }
 else
 {
  myservo.write(90);
           
}
}


Arduino Code for to read three sensor reading

Arduino Code for reading the sensor data and print and test

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

void loop()
{
  int state = analog Read(A0) ;
  int state2 = analog Read(A1) ;
  int state3 = analog Read(A3) ;
Serial. println ( state ) ;
delay ( 1000);
Serial. println ( state2 ) ;
delay ( 1000 );
Serial. println ( state3 ) ;
delay ( 1000 )  ;
}


JavaScript Object and XML interactively methods




More popular Sites -

Arduino Uno board Code for maje robot with defined pattern

Arduino Uno board Code for maje robot with defined pattern ROBOTIcs



#define left_motor 10             // Left motor speed control;
#define right_motor 11              // Controls speed of the right engine;
#define e1 8                        // Controls the direction of rotation of the left engine;
#define e2 9                        // Controls the direction of rotation of the left engine;
#define d1 12                       // Controls the direction of rotation of the right engine;
#define d2 13                       // Controls the direction of rotation of the right engine;
int trigger_front = A4;             // Controls the impulse sent from the front sensor
int echo_front = A5;                // Controls the pulse received from the front sensor
int trigger_left = A2;              // Controls the impulse sent from the front sensor
int echo_left = A3;                 // Controls the pulse received from the front sensor
int trigger_right = A0;             // Controls the impulse sent from the front sensor
int echo_right = A1;              // Controls the pulse received from the front sensor
                                  // Configuration of input types of variables declared;
void setup()
{
pinMode(trigger_front, OUTPUT);              // Arduino signal output trigger forward
pinMode(echo_front, INPUT);                  // Arduino signal input echo front
pinMode(trigger_left, OUTPUT);               // Arduino signal output trigger forward
pinMode(echo_left, INPUT);                   // Arduino signal input echo front
pinMode(trigger_right, OUTPUT);              // Arduino signal output trigger forward
pinMode(echo_right, INPUT);                   // Arduino signal input echo front
pinMode(left_motor, OUTPUT);                  // signal output from the Arduino's left engine speed
pinMode(right_motor, OUTPUT);                 // signal output of the right engine speed Arduino
pinMode(e1, OUTPUT);                          // Arduino signal output control the direction of rotation of the left engine
pinMode(e2, OUTPUT);                           // Arduino signal output control the direction of rotation of the left engine
pinMode(d1, OUTPUT);                           // Arduino signal output control the direction of rotation of the right engine
pinMode(d2, OUTPUT);                            // Arduino signal output control the direction of rotation of the right engine
}
                                                // code without endless repetition of the project;
void loop()
{
// declaration of variables used for project control;
long duration_front, duration_left, duration_right, rightt, leftt, front;
// It is declared the corresponding inputs and outputs//signal of the ultrasonic sensor and stored by the sensor that converts variable//the speed of sound is 340m / s or microseconds per centimeter, as // the signal goes and returns this time is the sensor half being = Time / 29/2; // thus follows also the other two sensors
digitalWrite(trigger_front, LOW);
delayMicroseconds(2);
digitalWrite(trigger_front, HIGH);
delayMicroseconds(5);
digitalWrite(trigger_front, LOW);
duration_front = pulseIn(echo_front, HIGH);
front = duration_front/29/2;
digitalWrite(trigger_left, LOW);
delayMicroseconds(2);
digitalWrite(trigger_left, HIGH);
delayMicroseconds(5);
digitalWrite(trigger_left, LOW);
duration_left = pulseIn(echo_left, HIGH);
rightt = duration_left/29/2;
digitalWrite(trigger_right, LOW);
delayMicroseconds(2);
digitalWrite(trigger_right, HIGH);
delayMicroseconds(5);
digitalWrite(trigger_right, LOW);
duration_right = pulseIn(echo_right, HIGH);
leftt = duration_right/29/2;
analogWrite(left_motor, 0); //block to initialize the inputs with pulse 0 // or off;
analogWrite(right_motor, 0); //
analogWrite(e1, 0); //
analogWrite(e2, 0); //
analogWrite(d1, 0); //
analogWrite(d2, 0); //
if(front>8)
{
//the use of the four if's down if within that are to control // handling robot,
// in order to keep it following the right wall straight;
if(rightt >8 && rightt< 13) // If the distance to the right wall // is between 9 and 12 cm, the robot remains straight;
{
analogWrite(left_motor, 120);
analogWrite(right_motor, 120);
analogWrite(e1, 255);
analogWrite(e2, 0);
analogWrite(d1, 0);
analogWrite(d2, 255);
}
if(rightt >=13) //If the distance to the right wall is greater than or equal to 13 cm, the robot increases its left engine speed to approach the right wall;
{
analogWrite(left_motor, 140);
analogWrite(right_motor, 100);
analogWrite(e1, 255);
analogWrite(e2, 0);
analogWrite(d1, 0);
analogWrite(d2, 255);
}
if(leftt <=8) // if in case the distance from the wall to the left is less than or equal to 8 cm, the robot increases its right engine speed to distance the left wall;
{
analogWrite(left_motor, 140);
analogWrite(right_motor, 100);
analogWrite(e1, 255);
analogWrite(e2, 0);
analogWrite(d1, 0);
analogWrite(d2, 255);
}
if(rightt <=8) // if in case the distance from the wall to the right is less than or equal to 8 cm, the robot increases its right engine speed to distance themselves from the right wall;
{
analogWrite(left_motor, 100);
analogWrite(right_motor, 140);
analogWrite(e1, 255);
analogWrite(e2, 0);
analogWrite(d1, 0);
analogWrite(d2, 255);
}
}
if(leftt <=20 && rightt>20 && front <=8) right(); //if in case the distance // front is less than or equal to 8 cm, the distance to the right is greater than 20 cm and the distance // the left is less than or equal to 20 cm it calls the function dir ();
if(leftt >20 && rightt>20 && front <=8) right(); //If the distance to the front // is less than or equal to 8 cm, the distance from the right is larger than 20 cm and the distance to left // is greater than 20 cm tell it calls the function ();
if(rightt <=20 && leftt>20 && front <=8) left(); //If the distance to the front // is less than or equal to 8 cm, the distance from the right is less than or equal to 20 cm and the distance from the left // is greater than 20 cm it calls the function Left ();
if(rightt <=20 && leftt<=20 && front <=8) voltar(); //if in case the distance // front is less than or equal to 8 cm, the distance to the right is less than or equal to 20 cm and the distance // the left is less than or equal to 20 cm it calls the function back ();
}
void left() //function to make the robot turn 90 left if he did not have exit the front and right;;
{
analogWrite(left_motor, 0);
analogWrite(right_motor, 0);
delay(100);
analogWrite(left_motor, 120);
analogWrite(right_motor, 120);
analogWrite(e1, 0);
analogWrite(e2, 255);
analogWrite(d1, 0);
analogWrite(d2, 255);
delay(700);
}
void right() // function to make the robot turn 90 right up if you do not exit the front or the left;
{
analogWrite(left_motor, 0);
analogWrite(right_motor, 0);
delay(100);
analogWrite(left_motor, 120);
analogWrite(right_motor, 120);
analogWrite(e1, 255);
analogWrite(e2, 0);
analogWrite(d1, 255);
analogWrite(d2, 0);
delay(800);
}
void voltar() // function to make the robot turn 180 if he did not have exit the front, right and left;
{
analogWrite(left_motor, 120);
analogWrite(right_motor, 120);
analogWrite(e1, 255);
analogWrite(e2, 0);
analogWrite(d1, 255);
analogWrite(d2, 0);
delay(1400);
}

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 code for Automatic ZCB operated by mobile Key pad

Arduino UNO Based Project Complete Code or Mobile Oprated JCB Demo. In this Project all the JCB can be operated directly via the Mobile Keypads and Or via a call and Key pad in the same way currently automatic call system of various serivce provider used to encode or pressed key frequecy.




int mot1=3;
int mot2=4;
int mot3=5;
int mot4=6;
int mot5=7;
int mot6=8;

void setup()
{
  Serial.begin(9600);
  pinMode(mot1,OUTPUT);
  pinMode(mot2,OUTPUT);
  pinMode(mot3,OUTPUT);
  pinMode(mot4,OUTPUT);
  pinMode(mot5,OUTPUT);
  pinMode(mot6,OUTPUT);
  }
  void loop()
  {
    digitalWrite(mot2,LOW);
    digitalWrite(mot3,LOW);
    digitalWrite(mot6,LOW);
    digitalWrite(mot1,HIGH);
    digitalWrite(mot4,HIGH);
    digitalWrite(mot5,HIGH);
    delay(1000);
    digitalWrite(mot1,LOW);
    digitalWrite(mot4,LOW);
    digitalWrite(mot5,LOW);
    digitalWrite(mot2,HIGH);
    digitalWrite(mot3,HIGH);
    digitalWrite(mot6,HIGH);
    delay(1000);
    }

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