lona21 发表于 2017-10-26 17:46:11

帮我整合一个代码


我想通过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 anew line
}


称重传感器Realplay+HX711模块称重传感器的代码也有
sd card shield v1.1代码有
DS 1370 RTC(时间记录)代码
都在附件
我想大家能不能帮我把整个的代码给整合起来,谢谢各位!

suoma 发表于 2017-10-28 10:03:08

没实现吗?是什么问题?我可以帮你做

lona21 发表于 2017-10-30 21:22:22

我是不太会再往下怎么弄,3个water传感器我已经写出来了,
再往下是把称重传感器Realplay+HX711程序写出来
再加上sd card shield v1.1(记录卡)、DS 1370 RTC(时间记录)的程序

要实现的是:3个water传感器、称重传感器Realplay+HX711模块称重传感器同时能够读取数据,把数据存到sd卡里,然后还得有时间

lona21 发表于 2017-11-1 14:39:19

suoma 发表于 2017-10-28 10:03
没实现吗?是什么问题?我可以帮你做

您能帮我就太好了

lona21 发表于 2017-11-4 17:57:06

suoma 发表于 2017-10-28 10:03
没实现吗?是什么问题?我可以帮你做

您说应该怎么弄

suoma 发表于 2017-11-4 21:19:34

lona21 发表于 2017-11-4 17:57
您说应该怎么弄

加QQ3455482668详聊
页: [1]
查看完整版本: 帮我整合一个代码