我想通过water传感器3个,和称重传感器Realplay+HX711模块称重传感器1个,同ARDUINO mega2560 、sd card shield v1.1(记录卡)、DS 1370 RTC(时间记录)、连接在一起,为的是实现将water传感器3个出现的数据和称重传感器Realplay+HX711模块称重传感器出来的数据,通过sd card shield v1.1(记录卡)记录,用DS 1370 RTC(时间记录)写入时间,water传感器3个的代码我已经写出:
// reading liquid flow rate using Seeeduino and Water Flow Sensor from hotmcu.com
// Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com
// http:/themakersworkbench.com http://thebestcasescenario.com http://hotmcu.com
volatile int NbTopsFan1; // measuring the rising edges of the signal
volatile int NbTopsFan2; // measuring the rising edges of the signal
volatile int NbTopsFan3; // measuring the rising edges of the signal
int Calc1;
int Calc2;
int Calc3;
int hallsensor1 = 2; // The pin location of the sensor
int hallsensor2 = 4; // The pin location of the sensor
int hallsensor3 = 7; // The pin location of the sensor
void rpm () // This is the function that the interupt calls
{
NbTopsFan1++;
NbTopsFan2++;
NbTopsFan3++; // This function measures the rising and falling edge of the hall effect sensors signal
}
void setup()
{
pinMode(hallsensor1, INPUT); // initializes digital pin 2 as an input
pinMode(hallsensor2, INPUT); // initializes digital pin 4 as an input
pinMode(hallsensor3, INPUT); // initializes digital pin 7 as an input
Serial.begin(9600); // This is the setup function where the serial port is initialised,
attachInterrupt(0, rpm, RISING);
attachInterrupt(2, rpm, RISING);
attachInterrupt(5, rpm, RISING); // and the interrupt is attached
}
void loop ()
{
NbTopsFan1 = 0; // Set NbTops to 0 ready for calculations
NbTopsFan2 = 0;
NbTopsFan3 = 0;
sei(); // Enables interrupts
delay (1000); // Wait 1 second
cli(); // Disable interrupts
Calc1 = (NbTopsFan1 * 60 / 4.5); // (Pulse frequency x 60) / 4.5Q, = flow rate in L/hour
Calc2 = (NbTopsFan2 * 60 / 4.5); // (Pulse frequency x 60) / 4.5Q, = flow rate in L/hour
Calc3 = (NbTopsFan3 * 60 / 4.5); // (Pulse frequency x 60) / 4.5Q, = flow rate in L/hour
Serial.print (Calc1, DEC); // Prints the number calculated above
Serial.print (Calc2, DEC); // Prints the number calculated above
Serial.print (Calc3, DEC); // Prints the number calculated above
Serial.print (" L/hour\r\n"); // Prints "L/hour" and returns a new line
}
称重传感器Realplay+HX711模块称重传感器的代码也有
sd card shield v1.1代码有
DS 1370 RTC(时间记录)代码
都在附件
我想大家能不能帮我把整个的代码给整合起来,谢谢各位! |