Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

multi analog sensor inputs and one output in arduino

Status
Not open for further replies.

sribangaram

Full Member level 5
Full Member level 5
Joined
Apr 29, 2012
Messages
297
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
INDIA.:/;:'" VIJAYAWADA
Activity points
3,754
Dear I need the program of arduino for 3 analog input's read and if input's are ok one output get's high so please give me the suggestion
 

Hi,

* A forum is not a place to ask soemone to do your job
* Show what you have done so far, what you expect and what does not work as expected.
* In case you find soemone to do this job for you .. he or she will need much more informations/specifications.

All in all your post is very close to be rated as "useless" in a forum.

Klaus
 

Dear Friend I have to write the Program but I con't complete the Program Because of my knowledge Please check the Program

PHP:
/*Conditionals - If statement

*/

// These constants won't change:
const int analogPin1 = PIN_A0;   // pin that the eb L1 sense
const int analogPin2 = PIN_A1;   // pin that the eb L2 sense 
const int analogPin3 = PIN_A2;   // pin that the eb L3 sense
const int analogPin4 = PIN_A3;   // pin that the dg L1 sense
const int analogPin5 = PIN_A4;   // pin that the dg L2 sense
const int analogPin6 = PIN_A5;   // pin that the dg L3 sense
const int ebconpin1 = 11;       // pin that the eb contactor
const int dgconPin2 = 12;       // pin that the dg contactor
const int threshold = 400;   // an arbitrary threshold level that's in the range of the analog input


void setup() {
  // initialize the LED pin as an output:
  pinMode(ebconpin1, OUTPUT);
  pinMode(dgconPin2, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // read the value of the potentiometer:
  int analog1Value = analogRead(analogPin1);
  int analog2Value = analogRead(analogPin2);
  int analog3Value = analogRead(analogPin3);
  

  // if the analog value is high enough, turn on the LED:
  if (analog1Value,analog2Value,analog3Value > threshold){
    delay(5000);        // delay in between reads for stability
    digitalWrite(dgconPin2, LOW);
    delay(5000);        // delay in between reads for stability
    digitalWrite(ebconpin1, HIGH);
  } else {
    digitalWrite(ebconpin1, LOW);


    // print the analog value:
  Serial.println(analog1Value);
  Serial.println(analog2Value);
  Serial.println(analog3Value);
  delay(1);        // delay in between reads for stability
  

    // read the value of the potentiometer:
  int analog4Value = analogRead(analogPin4);
  int analog5Value = analogRead(analogPin5);
  int analog6Value = analogRead(analogPin6);
  // if the analog value is high enough, turn on the LED:
  if (analog4Value,analog5Value,analog6Value > threshold){
    delay(20000);        // delay in between reads for stability
    digitalWrite(ebconpin1, LOW);
    delay(20000);        // delay in between reads for stability
    digitalWrite(dgconPin2, HIGH);
  } else {
    digitalWrite(dgconPin2, LOW);
  

 // print the analog value:
  Serial.println(analog4Value);
  Serial.println(analog5Value);
  Serial.println(analog6Value);
  delay(1000);        // delay in between reads for stability
}
}
}

Actually my requirement is ---- first read to EB SENSE(L1,L2,L3) three Analog's are OK then DG CON PIN LOW and delay time delay5 sec(required to adjustable) after EB CON PIN HIGH if any EB SENSE fail go and try to DG SENSE reading(L4,L5,L6) three Analog's are OK then EB CON PIN LOW and time delay 30 sec(required to adjustable) after then DG CON PIN HIGH If any DG SENSE fail try to DG START 5 crank's only it's for another OUT PUT PIN is requaired and it's in timer based for crank time like 3 sec or 4 sec or 5 sec I didn't add that pin in my program ---- when DG SENSE OK DG START PIN LOW and read to EB SENSE agin EB SENSE OK then add to another pin for DG STOP OUTPUT PIN it is also timer based like 30 sec or 40 or 50 sec So please cooperate to me
 

Dear friends I have to modify above program as my requirement but my problem is only timers are not working so please tell me ware is my mistake

PHP:
#include <plcLib.h>
/* Programmable Logic Controller Library for the Arduino and Compatibles
/*
  Conditionals - If statement


 */

// These constants won't change:
const int analogPin1 = PIN_A0;   // pin that the eb L1 sense
const int analogPin2 = PIN_A1;   // pin that the eb L2 sense 
const int analogPin3 = PIN_A2;   // pin that the eb L3 sense
const int analogPin4 = PIN_A3;   // pin that the dg L1 sense
const int analogPin5 = PIN_A4;   // pin that the dg L2 sense
const int analogPin6 = PIN_A5;   // pin that the dg L3 sense
const int ebconpin1 = 11;       // pin that the eb contactor
const int dgconPin2 = 12;       // pin that the dg contactor
const int startstoppin = 10;       // pin that the dg start & stop sense
const int smpspin = 9;       // pin that the dg batery charge
const int threshold = 400;   // an arbitrary threshold level that's in the range of the analog input
unsigned long TIMER0 = 0;  // Variable to hold elapsed time for Timer 0
unsigned long TIMER1 = 0;  // Variable to hold elapsed time for Timer 0


void setup() {
  // initialize the LED pin as an output:
  setupPLC();              // Setup inputs and outputs
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  10;
  // read the value of the potentiometer:
  int analog1Value = analogRead(analogPin1);
  int analog2Value = analogRead(analogPin2);
  int analog3Value = analogRead(analogPin3);
  
   
  if (analog1Value > threshold && analog2Value > threshold && analog3Value > threshold){
    delay(100);        // delay in between reads for stability
    digitalWrite(dgconPin2, LOW);
    delay(3000);        // delay in between reads for stability
    digitalWrite(ebconpin1, HIGH);
    timerOff(TIMER0, 30000);   // 30 second delay
    digitalWrite(startstoppin, LOW);
    
  } else {
    digitalWrite(ebconpin1, LOW);
    
    
  delay(100);        // delay in between reads for stability
  

    // read the value of the potentiometer:
  int analog4Value = analogRead(analogPin4);
  
  if (analog4Value >  threshold){
    delay(5000);        // delay in between reads for stability
    digitalWrite(ebconpin1, LOW);
    delay(5000);        // delay in between reads for stability
    delay(20000);        // delay in between reads for stability
    digitalWrite(dgconPin2, HIGH);
  } else {
    digitalWrite(dgconPin2, LOW);
    delay(100);        // delay in between reads for stability
    timerOn(TIMER1, 60000);   // 60 second delay
    digitalWrite(startstoppin, HIGH);
    delay(10);        // delay in between reads for stability
  }
  }

    // read the value of the potentiometer:
  int analog4Value = analogRead(analogPin4);

  // if the analog value is high enough, turn on the LED:
  if (analog4Value >  threshold){
    delay(10);        // delay in between reads for stability
    digitalWrite(smpspin, LOW);
    delay(5000);        // delay in between reads for stability
    } else {
    digitalWrite(smpspin, HIGH );
    
  }
  }
 

From where did you get this code. Post the link to it.
 

Friend thanks to reply friend timer out put's are not working

timerOff(TIMER0, 30000); // 30 second delay
digitalWrite(startstoppin, LOW);

timerOn(TIMER1, 60000); // 60 second delay
digitalWrite(startstoppin, HIGH);

ware I am mistake

- - - Updated - - -

From where did you get this code. Post the link to it.

Friend I have prepared my self
 

Where is the link for timer library ?
 

Friend now i am adding library but now also same please check

PHP:
#include <TimerOne.h>


#include <plcLib.h> 
/* Programmable Logic Controller Library for the Arduino and Compatibles 
/* 
  Conditionals - If statement 


 */ 

// These constants won't change: 
const int analogPin1 = PIN_A0;   // pin that the eb L1 sense 
const int analogPin2 = PIN_A1;   // pin that the eb L2 sense  
const int analogPin3 = PIN_A2;   // pin that the eb L3 sense 
const int analogPin4 = PIN_A3;   // pin that the dg L1 sense 
const int analogPin5 = PIN_A4;   // pin that the dg L2 sense 
const int analogPin6 = PIN_A5;   // pin that the dg L3 sense 
const int ebconpin1 = 11;       // pin that the eb contactor 
const int dgconPin2 = 12;       // pin that the dg contactor 
const int startstoppin = 10;       // pin that the dg start & stop sense 
const int smpspin = 9;       // pin that the dg batery charge 
const int threshold = 400;   // an arbitrary threshold level that's in the range of the analog input 
unsigned long TIMER0 = 0;  // Variable to hold elapsed time for Timer 0 
unsigned long TIMER1 = 0;  // Variable to hold elapsed time for Timer 0 


void setup() { 
  // initialize the LED pin as an output: 
  setupPLC();              // Setup inputs and outputs 
  // initialize serial communications: 
  Serial.begin(9600); 
} 

void loop() { 
   
  // read the value of the potentiometer: 
  int analog1Value = analogRead(analogPin1); 
  int analog2Value = analogRead(analogPin2); 
  int analog3Value = analogRead(analogPin3); 
   
    
  if (analog1Value > threshold && analog2Value > threshold && analog3Value > threshold){ 
    delay(100);        // delay in between reads for stability 
    digitalWrite(dgconPin2, LOW); 
    delay(3000);        // delay in between reads for stability 
    digitalWrite(ebconpin1, HIGH); 
    timerOff(TIMER0, 30000);   // 30 second delay 
    digitalWrite(startstoppin, LOW); 
     
  } else { 
    digitalWrite(ebconpin1, LOW); 
     
     
  delay(100);        // delay in between reads for stability 
   

    // read the value of the potentiometer: 
  int analog4Value = analogRead(analogPin4); 
   
  if (analog4Value >  threshold){ 
    delay(5000);        // delay in between reads for stability 
    digitalWrite(ebconpin1, LOW); 
    delay(5000);        // delay in between reads for stability 
    delay(20000);        // delay in between reads for stability 
    digitalWrite(dgconPin2, HIGH); 
  } else { 
    digitalWrite(dgconPin2, LOW); 
    delay(100);        // delay in between reads for stability 
    timerOn(TIMER1, 60000);   // 60 second delay 
    digitalWrite(startstoppin, HIGH); 
    delay(10);        // delay in between reads for stability 
  } 
  } 

    // read the value of the potentiometer: 
  int analog4Value = analogRead(analogPin4); 

  // if the analog value is high enough, turn on the LED: 
  if (analog4Value >  threshold){ 
    delay(10);        // delay in between reads for stability 
    digitalWrite(smpspin, LOW); 
    delay(5000);        // delay in between reads for stability 
    } else { 
    digitalWrite(smpspin, HIGH ); 
     
  } 
  }
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top