programming different sensors

I have programmed different sensors, is it possible, but I am facing difficulty in that, to help me solve this problem, knowing that I am a chemistry major and do not know the programming language I designed this code according to the sensors I have

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS A1
#define ONE_WIRE_BUS A2
OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

int flowPin = 12;
int volume=11;
double flowRate; //This is the value we intend to calculate.
volatile int count;
int heat = analogRead(A1);
int temp = analogRead(A2);//This integer needs to be set as volatile to ensure it updates correctly during the interrupt process.
int pin5=5;
int pin3=3;
int pin4=4;
int pin6=6;
int pin7=7;

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

pinMode(flowPin, INPUT);
pinMode(volume, INPUT);
pinMode (pin5,OUTPUT);
pinMode (pin3,OUTPUT);
pinMode (pin4,OUTPUT);
pinMode (pin6,OUTPUT);
pinMode (pin7,OUTPUT);

//Sets the pin as an input
attachInterrupt(0, Flow, RISING);
Serial.begin(9600);
}
void Flow()
{
count++;
}
void loop()
{
me:

count = 0;
interrupts();
delay (1000);
noInterrupts();

{int heat = analogRead(A1);
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0); // the index 0 refers to the first device
float tempF = sensors.getTempFByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.print("C ");
delay(100);

if (tempC <= 30){
digitalWrite (pin3,HIGH);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
digitalWrite (pin6,LOW);
digitalWrite (pin7,LOW);

}
if (tempC <= 30){
goto me;
digitalWrite (pin3,HIGH);
delay(5000);
}

else {
delay(5000);
digitalWrite (pin3,LOW);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,LOW);
digitalWrite (pin6,LOW);
digitalWrite (pin7,LOW);
delay(3000);

}
}

{int flowPin = 12;
flowPin = (count * 2.25); //Take counted pulses in the last second and multiply by 2.25mL
Serial.println(flowPin);
delay (1000);
if (flowPin<=15) {
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,HIGH);
digitalWrite (pin6,LOW);
digitalWrite (pin7,LOW);
delay(3000);
}
else
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
digitalWrite (pin6,LOW);
digitalWrite (pin7,LOW);
Serial.println(flowRate);
delay (1000);

}
{int volume =11;
volume = (count * 2.25); //Take counted pulses in the last second and multiply by 2.25mL
Serial.println(volume);
delay (1000);
if (volume<=45) {
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
digitalWrite (pin6,HIGH);
digitalWrite (pin7,LOW);
delay(3000); }
else
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
digitalWrite (pin6,LOW);
digitalWrite (pin7,LOW);
delay (1000);
Serial.println(flowRate);
delay (1000);
}

{int temp = analogRead(A2);

sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0); // the index 0 refers to the first device
float tempF = sensors.getTempFByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.print("C ");

delay(100);
if (tempC>=30){

digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
digitalWrite (pin6,LOW);
digitalWrite (pin7,HIGH);

delay(1000);
}

else{
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
digitalWrite (pin6,LOW);
digitalWrite (pin7,LOW);

}
}

}

You will find that the first problem stems from your lack of knowledge on how to properly post code. How to properly post code is in a forum thingy that you elected not to read. Go back, learn how to properly post code, and edit your original posting to properly display posted code.

Hello
I ´ve stopped reading when I read coded delay()´s and an ISR in your sketch.

The OP would do well with using the autoformat feature of the Arduino IDE to find little buggie-boo's like the one posted abvoe.

And @faiad78 did not say what the program is doing that it shouldn't, or not doing what it should, so.

What is the problem with your code at this time?

a7

Earlier, you were using flowPin as a pin number (used in a pinMode as INPUT), now it looks like it's a general purpose variable.

Edit: that's another variable called flowPin.
That's not at all confusing.

Hi, @faiad78
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

  1. Can you please tell us what sensors you are using?
  2. What you are using as outputs?
  3. What is your code doing?
  4. What do you want your code to do?
  5. Have you written code for each sensor separately to prove you can read them?
  6. Can you please post a circuit diagram?
  7. What model Arduino are you using?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

@faiad78
Will you provde answers to the following questions so that help could be extended to you?

1. Temperature Sensor tyep -- is it DS18B20?
2. How many sensors do you have: 2?
3. How do you want to use the temperature value of Sensor-1?
4. How do you want to use the temperature value of Sensor-2?
5. Are you using Arduino UNO?

the compnents
1- Arduino Uno
2- Two temperature sensors, type DS18B20.
3- Two flowmeter sensors type YF-S201.
Required
1- Programming the first temperature sensor, and when the temperature reaches 60 degrees, pin No. 5 is lit for 10 minutes, then pin No. 5 is turned off for a period of minutes, and pin No. 6 is lit for three minutes, then it is turned off
2- Programming the first flowmeter sensor to light up pin 7, and when the volume reaches 50 ml, the pin is turned off.
3- Programming the second flowmeter sensor to light up pin 8, and when the volume reaches 50 ml, the pin is turned off.
4- Programming the second temperature sensor, and when the temperature reaches 45 degrees, pin No. 9 is lit for 10 minutes, after which the pin is turned off.
I would be grateful if you could complete the programming for me

Hi,
Thanks for the explanation.
I presume the pins that are lit are output pins to LEDs or some other indicator.

What does your code do now?
What are the problems?

Can you please post a circuit diagram of your project?

Thanks.. Tom... :smiley: :+1: :coffee: :australia: :astonished:

hello dear



I would like to inform you that my major is chemistry and not programming and that my knowledge of programming is the same as your knowledge of chemistry, so do not stop reading the sketch and try to help me with many thanks

‫في الاثنين، 23 أغسطس 2021 في 3:23 م تمت كتابة ما يلي بواسطة ‪Paul-Paulson via Arduino Forum‬‏ <‪arduino@discoursemail.com‬‏>:‬

i dont know what to do

‫في الثلاثاء، 24 أغسطس 2021 في 1:16 م تمت كتابة ما يلي بواسطة ‪Mohammed faiad‬‏ <‪faiad78@gmail.com‬‏>:‬

The following procedures will satisfy the Step-1 of your requirements of Post-9. Please, follow the comments put against the code lines to undersyand the programming art.

1. Build the following setup using one Temperature Sensor and two LEDs.

ds18b20-4
Figure-1:

2. Upload the following sketch (tested in UNO):

#include <OneWire.h>
#include <DallasTemperature.h>

OneWire oneWire(2); //Sensor signal pin is connected with DPin-2
DallasTemperature sensors(&oneWire);// Pass our oneWire reference to Dallas Temperature.

void setup(void)
{
  Serial.begin(9600); // start serial port
  sensors.begin();    // Start up the library
  pinMode(5, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop()
{
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.print("Temperature from Sensor-1: ");
  float myTemp = sensors.getTempCByIndex(0);
  Serial.print(myTemp, 2);
  Serial.println("  *C");
  //----------------------------------------
  if (myTemp >= 30.00)  //test temperature
  {
    digitalWrite(5, HIGH);   //LED2 is turned on
    delay(10 * 60 * 1000UL); //10*60*1000 ms = 10 minute; UL = unsigned long = 2^32
    digitalWrite(5, LOW);  //LED2 is turned off
    delay(1*60*1000UL);  //1 minute
    //----------------------
    digitalWrite(13, HIGH);   //L is turned on
    delay(3*60*1000UL);       //3 minutes
    digitalWrite(13, LOW);   //L is turned off
  }
}

3. Check that LED2 and L behaves according to the escription of the sketch of Step-2.

4. Connect Sensor-2 in pararllel with Sensor-1 of Fig-1.
5. Add necessary codes with sketch of Step-2 to handle Sensor-2.

Hello
You are a smart and togh guy and either I recommend to take some lectures about:

  1. Realtime Systems Design
  2. OOP
  3. IPO Model

or
drop your request in the section Jobs and Paid Consultancy.

Are you able to autoformat your code? Can you learn how to post your code in code tags? If you can learn how to use code tags, will you repost your formatted code in code tags?

dear sir
i would to thank you about your cooperation but i must put 2 temperature sensors and 2 flow meter sensors in the same circuit so i must but all the three in one sketch if you can help me i will appreciate that for you

‫في الثلاثاء، 24 أغسطس 2021 في 2:11 م تمت كتابة ما يلي بواسطة ‪gm via Arduino Forum‬‏ <‪arduino@discoursemail.com‬‏>:‬

thanks for your help???/

‫في الثلاثاء، 24 أغسطس 2021 في 3:17 م تمت كتابة ما يلي بواسطة ‪Idahowalker via Arduino Forum‬‏ <‪arduino@discoursemail.com‬‏>:‬

Are you able to autoformat your code? Can you learn how to post your code in code tags? If you can learn how to use code tags, will you repost your formatted code in code tags?

If you want more help, you have sit for quiz now:
Write answer to the following questions after reading the sketch of Post-13.
1. Have you uploaded the sketch of Post-13? Is it working? If so, post the readings of the Serial Monitor.

2. Tell us the names of the Libraries that have been used in Post-13.
3. What is the difference between float data type and int data type?
4. More questions are coming once you have answered to the above questions.