Go Down

Topic: Programming sensors & actuators with arduino (Read 31 times) previous topic - next topic

Vasumathi

I am doing a project on waste management. I have to separate waste majorly as metal, plastic and other materials. For that using Arduino Mega 2560. I have connected Inductive proximity sensor @ A0(Anolog pin 1 of arduino) & Capacitive proximity Sensor @ A1(analog pin 2 of arduino). The two 5v dc motor which are to be used as actuators when the sensors sense the object.
I have given 12 v to the 2 sensors & I have directly connected the sensor's output pin with arduino.

If the Inductive sensor senses any metal object in the conveyor, the dc motor which is a actuator here has to rotate forward, wait sometime & to rotate reverse and stay until the next sense started.
the same for capacitive sensor.

But the problem was there is even though the sensor is not sensing the motor is running. The motor keeps on running forward, delayed and reverse. Plz help me out for this, I don't know where I have done the mistake.

The program I have tried is here:

#define motorpin1 4 \\dc motor's pin 1
#define motorpin2 5 \\dc motor's pin 2
#define motorpin3 6 \\dc motor's pin 3
#define motorpin4 7 \\dc motor's pin 4


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT); 
  pinMode(9,OUTPUT);

 
}

void loop() {
  // put your main code here, to run repeatedly:
if((analogRead(A0)<400) && (analogRead(A0)>100)
{
  digitalWrite(motorpin1,HIGH);
  digitalWrite(motorpin2,LOW);
  delay(5000);
  digitalWrite(motorpin1,LOW);
  digitalWrite(motorpin2,HIGH);
  delay(5000);
  digitalWrite(motorpin1,LOW);
  digitalWrite(motorpin1,LOW);
 
}
if((analogRead(A1)<400) && (analogRead(A1)>100)
{
  digitalWrite(motorpin3,HIGH);
  digitalWrite(motorpin4,LOW);
  delay(5000);
  digitalWrite(motorpin3,LOW);
  digitalWrite(motorpin4,HIGH);
  delay(5000);
  digitalWrite(motorpin3,LOW);
  digitalWrite(motorpin4,LOW);
 
}

Go Up