我是靠谱客的博主 时尚向日葵,最近开发中收集的这篇文章主要介绍基于Arduino、ESP8266的物联网项目开发方案整理、毕业设计(第二波),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

文章目录

    • 1、背景
    • 2、项目整理
      • 2.1 Home Office —— 在家办公时调节休息的灯
        • 2.1.1 功能介绍
        • 2.1.2 实物图片
        • 2.1.3 视频
        • 2.1.4 源代码
      • 2.2 仿生珊瑚
        • 2.2.1 功能介绍
        • 2.2.2 实物图片
        • 2.2.3 视频
        • 2.2.4 源代码
      • 2.3 气体传感器 —— 气体检测
        • 2.3.1 功能介绍
        • 2.3.2 实物图片
        • 2.3.3 视频
        • 2.3.4 源代码
      • 2.4 气体采集平台
        • 2.4.1 功能介绍
        • 2.4.2 实物图片
        • 2.4.3 视频
        • 2.4.4 源代码
    • 3、如何联系我们

博主联系方式汇总(非诚勿扰)
博主联系方式汇总(非诚勿扰)
博主联系方式汇总(非诚勿扰)

1、背景

了解博哥的同学都知道,作为一名电子爱好者,博哥除了平时乐于分享基础知识之外,还需要肩负起减轻家庭负担的责任(毕竟从农村走出来的孩子)。

目前,一般加博哥好友的人大概可以分为两类:

  • 学习知识(这一部分目前基本上都很正常运转起来,更多人还是喜欢我的ESP8266开发系列,主要着重点在于基础)
  • 项目开发、毕业设计等(这一部分内容缺失,没有一系列的帖子去记录过博哥有经历过哪些项目开发,不一定是我开发的。。。。)

所以,经过仔细考虑还是需要去介绍一下一些项目开发整理。

2、项目整理

主要分为几个项目:

  • Home Office
  • 仿生珊瑚
  • 气体传感器
  • 气体采集平台

2.1 Home Office —— 在家办公时调节休息的灯

2.1.1 功能介绍

  • 0、用户A是个设计师,疫情在家工作也常常要加班。大量的工作很容易让他烦躁并且缺乏休息(用户背景)
  • 1、当时间到达T1(hh1:mm1:ss1)时、表示上班时间到了。随着时间的推移,光线会慢慢变暗(人工拉动窗帘或者遮挡光敏传感器)如果光敏电阻检测到环境暗,则灯环自动亮暖色(环境越暗灯环越亮)。//这里是避免由于忘记开灯,伤害眼睛
  • 2、连续亮了t分钟后,灯变暗变绿色呼吸灯效果, MP3模块播放音乐,提醒用户A休息。
  • 3、 只有当人手摸着心率/心跳传感器,检测到稳定(舒畅的状态)时,心跳稳定且平静则恢复1中的暖光,这时重新计时t。//比如像我这种工作狂 灯一灭就想立刻重启继续,那就要心跳传感器给予验证,脉搏是OK的才行
  • 4、需要去休息时,点击开关按钮, 灯进入休眠(关闭灯),到第二天的T2(hh2:mm2:ss2)再次开启。
  • 5、测试的时候,T1和T2可以设置的间隔短一点,比如5分钟。

2.1.2 实物图片

1、1Arduino nano或uno
2、1
DS3231时钟模块(含纽扣电池)
3、1光敏电阻(模块)
4、1
24位 WS2812LED灯环
5、1无源蜂鸣器/mp3模块
6、1
心率传感器/心跳传感器
7、1*9v电池
8、其他可能需要的元器件(面包板、按钮、电阻、电容、导线等)

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.1.3 视频

演示视频暂时无法上传(需要的可以另外帖子留言

2.1.4 源代码

#include <DS3231.h>
#include <Wire.h>
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
bool work_flag = 1;
int flag = 0;        //调试用
int second,minute,hour,date,month,year,temperature; 


#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>

const int OUTPUT_TYPE = SERIAL_PLOTTER;

const int PULSE_INPUT = A0;
const int PULSE_BLINK = 13;    // Pin 13 is the on-board LED
const int PULSE_FADE = 5;
const int THRESHOLD = 530;   // Adjust this number to avoid noise when idle
int BPM = 0;

int old_min = 0;
PulseSensorPlayground pulseSensor;

#include <Adafruit_NeoPixel.h>

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

#define button_1  2               //按钮引脚 
#define LED_PIN       7         //LED引脚
#define NUMPIXELS     24           //LED数量
#define Bright_PIN    A1        //光感引脚
#define hode_time     1000          //闪烁速度调节
#define work_time_hour     16           //工作时间h
#define work_time_min      10           //工作时间min      
#define wake_time_hour     9            //唤醒时间h
#define wake_time_min     20           //唤醒时间min
#define rest_time       1             //休息提醒时长间隔
#define rest_time_delay    15          //休息时长(单位S)

int Set_BPM = 180;                         //设置舒缓心率
int Set_Min_BPM = 140;
Adafruit_NeoPixel pixels(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

int LED_num = 24;
int LED_flag = 0;
bool play_flag = 1;
int LED_Bright = 200;                 //LED亮度设置 0-255
unsigned long int cur_time = 0;        //LED渐变初始时间
unsigned long int Readtime = 0;
void setup() {
  Wire.begin();
//        Clock.setSecond(50);//Set the second 
//        Clock.setMinute(8);//Set the minute 
//        Clock.setHour(0);  //Set the hour 
//        Clock.setDoW(4);    //Set the day of the week
//        Clock.setDate(9);  //Set the date of the month
//        Clock.setMonth(7);  //Set the month of the year
//        Clock.setYear(20);  //Set the year (Last two digits of the year)
  ReadDS3231();
  old_min = minute;
  pixels.begin();
  pixels.setBrightness(LED_Bright);
  mySoftwareSerial.begin(9600);

  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
//    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));

  myDFPlayer.volume(30);  //Set volume value. From 0 to 30
  Serial.begin(115200);
  pinMode(button_1,INPUT);              //按钮设置为输入
  pulseSensor.analogInput(PULSE_INPUT);
  pulseSensor.blinkOnPulse(PULSE_BLINK);
  pulseSensor.fadeOnPulse(PULSE_FADE);

  pulseSensor.setSerial(Serial);
  pulseSensor.setOutputType(OUTPUT_TYPE);
  pulseSensor.setThreshold(THRESHOLD);
  if (!pulseSensor.begin()) {
    for(;;) {
      digitalWrite(PULSE_BLINK, LOW);
      delay(50);
      digitalWrite(PULSE_BLINK, HIGH);
      delay(50);
    }
  }
}

/********按钮结构体*********/
struct Button{
  int buttonState;                     //按钮状态变量
  int lastButtonState = LOW;           //按钮状态初始化
  long lastDebounceTime = 0;           //记录抖动变量
  long debounceDelay = 50;             //抖动时间变量50ms
};
Button button1;                         //新建1个按钮

/********按钮消抖函数********/
bool GetButton(){                    
  int reading = digitalRead(button_1);  //读取I/O口状态
  if(reading!=button1.lastButtonState){ //如果状态发生改变
    button1.lastDebounceTime = millis();//更新时间
  }                                    //如果等待时间大于debounceDelay
  if((millis()-button1.lastDebounceTime)>button1.debounceDelay){
    if(reading!=button1.buttonState){   //读取状态不等于按钮状态
      button1.buttonState = reading;    //更新buttonState
    }
  }
  button1.lastButtonState = reading;    //更新lastButtonState
  return button1.lastButtonState;
}

void loop() {
  ReadDS3231();
  Mode_Change();              //模式刷新
  LED_Run();                  //LED状态刷新
}

void Mode_Change(){
  if(millis() - Readtime > 1000){  
    Serial_OUT();
    Readtime = millis();
    ReadDS3231();                //获取时间
    if(flag == 1 || hour > work_time_hour || (hour == work_time_hour && minute >= work_time_min)){
      if(work_flag == 1){
        Mode_1();                              //工作时间内为模式1
//        Serial.println("Mode_1");
        if(GetButton()){               //如果按钮按下,进入睡眠模式
          work_flag = 0;
//          Serial.println("GetButton()");
        }
      }   
    }
    else if(flag == 2 || hour > wake_time_hour  || (hour = wake_time_hour && minute < wake_time_min )){
        Mode_2();                               //唤醒后切换为模式2
        work_flag = 1;
//        Serial.println("Mode_2");
    }
    if(flag == 3 || work_flag == 0){                        //睡眠模式
      Mode_3();
//      Serial.println("Mode_3");
    }   
  }
}
  
void Mode_1(){
  int x = minute - old_min;
//  Serial.println(x);
  ReadDS3231();
  if(minute - old_min >= rest_time){
    pulseSensor.begin();         //开始读取心率
    Get_BPM();
    if(play_flag == 1){
      myDFPlayer.play(1);  //Play the first mp3
      play_flag = 0;
    }
    LED_flag = 2;
    if(Clock.getSecond() > rest_time_delay){
//    if(BPM > Set_Min_BPM && BPM < Set_BPM){
      old_min = minute;
      BPM = 0;
      }
  }
  else{
    pulseSensor.pause();         //暂停读取心率
    LED_flag = 1;
    myDFPlayer.stop();  //Play the first mp3
    play_flag = 1;
  }
}
void Mode_2(){
  pulseSensor.pause();         //暂停读取心率
  work_flag = 1;
  LED_flag = 1;
}
void Mode_3(){
  pulseSensor.pause();         //暂停读取心率
  LED_flag = 0;
}

/********获取时间函数********/
void ReadDS3231(){
  second=Clock.getSecond();
  minute=Clock.getMinute();
  hour=Clock.getHour(h12, PM);
  date=Clock.getDate();
  month=Clock.getMonth(Century);
  year=Clock.getYear();
//  temperature=Clock.getTemperature();
//    Serial.print("20");
//    Serial.print(year,DEC);
//    Serial.print('-');
//    Serial.print(month,DEC);
//    Serial.print('-');
//    Serial.print(date,DEC);
//    Serial.print(' ');
//    Serial.print(hour,DEC);
//    Serial.print(':');
//    Serial.print(minute,DEC);
//    Serial.print(':');
//    Serial.print(second,DEC);
//    Serial.print('n');
//  Serial.print("Temperature=");
//  Serial.print(temperature); 
//  Serial.print('n');

}

/********LED状态刷新********/
void LED_Run(){
  if(LED_flag == 0){          //灯灭
    pixels.clear();
    pixels.show();
  }
  
  else if(LED_flag == 1){         //自动调整LED亮度
    LED_Bright = map(analogRead(Bright_PIN),0,1024,0,255);//获取亮度
    for(int m = 0; m < (LED_num+1); m++){
      pixels.setPixelColor(m, pixels.Color(255, 255, 255));
    }
    pixels.setBrightness(LED_Bright);      //调节亮度
    pixels.show();                     //更新亮度
  }
  
  else if(LED_flag == 2){             //LED闪烁提醒
    cur_time = millis();
    if((cur_time % (2*hode_time)) > hode_time){ //防阻塞LED闪烁
      pixels.clear();
    }
    else{
      LED_Bright = map(analogRead(Bright_PIN),0,1024,0,255);//获取亮度
      for(int m = 0; m < (LED_num+1); m++){
        pixels.setPixelColor(m, pixels.Color(0, 255, 0));
        pixels.setBrightness(LED_Bright);
      }
    }
    pixels.show();
  }
}

void Get_BPM(){
  delay(20);
  //pulseSensor.outputSample();
  if (pulseSensor.sawStartOfBeat()) {
    BPM = pulseSensor.getBeatsPerMinute();
   Serial.println(BPM);
  }
}

void Serial_OUT(){
  Serial.print("Temperature=");
  Serial.print(temperature); 
  Serial.print('n');
  Serial.print("20");
  Serial.print(year,DEC);
  Serial.print('-');
  Serial.print(month,DEC);
  Serial.print('-');
  Serial.print(date,DEC);
  Serial.print(' ');
  Serial.print(hour,DEC);
  Serial.print(':');
  Serial.print(minute,DEC);
  Serial.print(':');
  Serial.print(second,DEC);
  Serial.print('n');
  int B = map(analogRead(Bright_PIN),0,1024,1024,0);
  Serial.print("Bright: ");
  Serial.print(B);
  Serial.print("tBPM: ");
  Serial.println(BPM);
  BPM = random(60,200);
  Serial.println("--------------------------");
}

2.2 仿生珊瑚

2.2.1 功能介绍

在这里插入图片描述

  • 1、用户通过在触控板绘制上图“米”字所示的横线“一”,“|”,“╱”,“╲”这四个的任意一个,来控制圆盘上面的塑料柱。
  • 2、举个例子,当客户绘制“一”后,就从如右上图这排(记为A)开始,往两边扩散形成水波效果。具体的时间就是,A在1s内下去1cm,然后在1s内又复原。在A开始下去的0.3s后,A两边的也开始在1s下去。如此控制,直到最外边的也控制完。
  • 3、当TDS模块采集的值超过250时,圆盘由最中心的点,往外扩散,形成水滴散开的效果。
  • 4、最好是可以支持绘制“~”型图案。

在这里插入图片描述
在这里插入图片描述

2.2.2 实物图片

1、1Arduino uno 或 mega
2、1
TDS模块
3、37电机
4、1
无线模块
5、1接收模块
6、1
触摸板

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.2.3 视频

演示视频暂时无法上传(需要的可以另外帖子留言

2.2.4 源代码

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <SoftwareSerial.h>

/*舵机驱动板IIC地址*/
Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver();  //默认地址0x40
//Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);
/*
 * PCA9685可以设置更新频率,时基脉冲周期20ms相当于50HZ更新频率,
 * PCA9685采用12位的寄存器来控制PWM占比,对于0.5ms,相当于0.5/20*4096=102的寄存器值
 * 但是实际使用的时候,还是有偏差,除了0度以及180度,其他需要乘以0.915系数
 * 0.5ms———— 0度:0.5/20*4096 = 102
 * 1.0ms———— 45度:1/20*4096 = 204*0.915 = 187
 * 1.5ms———— 90度:1.5/20*4096 = 306*0.915 = 280
 * 2.0ms———— 135度:2/20*4096 = 408*0.915 = 373
 * 2.5ms———— 180度:2.5/20*4096 = 512
 * 30度=0.5ms+(30/180)*(2.5ms-0.5ms)=0.8333ms
 * 0.8333ms/20ms=off/4096,off=171,171*0.915=156
 * 60度=0.5ms+(60/180)*(2.5ms-0.5ms)=1.666ms
 * 1.666ms/20ms=off/4096,off=239,239*0.915=219
 */
/*舵机转动角度*/
#define SERVO_0   102 
#define SERVO_30  156
#define SERVO_45  187
#define SERVO_60  219 
#define SERVO_90  280 
#define SERVO_135 373 
#define SERVO_180 512 
/*舵机转动时间间隔*/
#define interval0  300
/*TDS传感器相关定义*/
#define TdsSensorPin A0
#define VREF         5.0  //ADC的模拟参考电压(伏特)
#define SCOUNT       30   //采样点和
int analogBuffer[SCOUNT]; //将模拟值存储在数组中,从ADC中读取
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0,copyIndex = 0;
float averageVoltage = 0,tdsValue = 0,temperature = 25;
/*蓝牙数据接收相关定义*/
unsigned char c[10] = {0x00};
unsigned char Length = 0;
SoftwareSerial BTSerial(3, 2);  //RX(D3),TX(D2)
bool flag;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  BTSerial.begin(9600);
  pinMode(TdsSensorPin,INPUT);  //初始化TDS传感器接口
  flag=true;
  pwm1.begin();                //复位并初始化舵机驱动板
  //pwm2.begin();
  pwm1.setPWMFreq(50);        //调节PWM频率,范围40-1000Hz
  //pwm2.setPWMFreq(50);
  Servo_Init();               //舵机初始化
}

void loop() {
  //put your main code here, to run repeatedly:
  static unsigned long analogSampleTimepoint = millis();
  if(millis() - analogSampleTimepoint > 80U)  //每80毫秒,从ADC中读取模拟值
  {
    analogSampleTimepoint=millis();
    analogBuffer[analogBufferIndex]=analogRead(TdsSensorPin); //读取模拟值,每80毫秒存入缓冲区
    analogBufferIndex++;
    if(analogBufferIndex == SCOUNT)
      analogBufferIndex = 0;
  }
  static unsigned long printTimepoint = millis();
  if(millis() - printTimepoint > 6000U)
  {
    printTimepoint = millis();
    for(copyIndex=0;copyIndex < SCOUNT;copyIndex++)
    {
      analogBufferTemp[copyIndex] = analogBuffer[copyIndex];
      averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF / 1024.0;  //通过中值滤波算法读取更稳定的模拟值,并转换为电压值
      float compensationCoefficient = 1.0+0.02*(temperature - 25.0);  //温度补偿公式:fFinalResult(25^C) = fFinalResult(current)/(1.0+0.02*(ft -25.0));
      float compensationVolatge = averageVoltage / compensationCoefficient; //温度补偿
      tdsValue = (133.42*compensationVolatge*compensationVolatge*compensationVolatge - 
                  255.86*compensationVolatge*compensationVolatge + 857.39*compensationVolatge)*0.5; //将电压值转换为tds值进行温度补偿
//       Serial.print("voltage:");
//       Serial.print(averageVoltage,2);
//       Serial.print("V ");
//       Serial.print("TDS Value:");
//       Serial.println(tdsValue,0);
//       Serial.println("ppm");
    }
    BTSerial.print("t0.txt="");//蓝牙发送数据
    BTSerial.print(tdsValue);
    Serial.println(tdsValue);
    BTSerial.print("ppm");
    BTSerial.print(""");
    BTSerial.write(0xff);
    BTSerial.write(0xff);
    BTSerial.write(0xff);
  }
  
  Length = 0; 
  while(BTSerial.available()>0)
  {
      c[Length++] = BTSerial.read(); //接收蓝牙数据
  }
  if (Length > 0)
  {
    if(c[0] ==0x3 || c[0] ==0x5) 
    {
      Serial.println("03");
      if(flag==true)
        Draw_HorLine();
    }
    else if(c[0] == 0x1 || c[0] == 0x7)
    {
      Serial.println("01");
      if(flag==true)
        Draw_VerLine();
    }
    else if(c[0] == 0x2|| c[0] == 0x6)
    {
      Serial.println("02");
      if(flag==true)
        Draw_LeftLine();
    }
    else if(c[0] == 0x0 || c[0] == 0x8)
    {
      Serial.println("00");
      if(flag==true)
        Draw_RightLine();
    }
    Length = 0;  
  }
}

//舵机初始化
//setPWM(channel, on, off) 
//channel:更新的通道
//on:信号从低电平变为高电平的滴答(在0…4095之间)
//off:当信号从高电平变为低电平时的滴答(在0…4095之间)
void Servo_Init(void)
{
  Serial.println("舵机初始化开始"); 
  for(uint16_t channel=0;channel<=12;channel++)
  {
    pwm1.setPWM(channel,0,SERVO_180);
  }
  for(uint16_t channel=0;channel<=7;channel++)
  {
    //pwm2.setPWM(channel,0,SERVO_180);
  }
  delay(50);
  for(uint16_t channel=0;channel<=12;channel++)
  {
    pwm1.setPWM(channel,0,SERVO_0);
  }
  for(uint16_t channel=0;channel<=7;channel++)
  {
    //pwm2.setPWM(channel,0,SERVO_0);
  }
  Serial.println("舵机初始化完成");
}

//中值滤波
int getMedianNum(int bArray[],int iFilterLen) 
{
  int bTab[iFilterLen];
  int i,j,bTemp;

  for(byte i=0;i<iFilterLen;i++)
  {
    bTab[i]=bArray[i];
  }
  for(j=0;j<iFilterLen-1;j++)
  {
    for(i=0;i<iFilterLen-j-1;i++)
    {
      if(bTab[i] > bTab[i+1])
      {
        bTemp=bTab[i];
        bTab[i]=bTab[i+1];
        bTab[i+1]=bTemp;
      }
    }
  }
  if((iFilterLen & 1) > 0)
    bTemp=bTab[(iFilterLen -1) / 2];
  else
    bTemp=(bTab[iFilterLen / 2] + bTab[iFilterLen / 2 - 1]) / 2;
  return bTemp;
}

void Draw_HorLine() //画横线
{
  flag=false;
  if(tdsValue <= 250)
  {
    /*
     *假设3、5、5、5、3分别记为A、B、C、D、E
    */
    for(uint16_t channel=0;channel<=4;channel++)  //T=0s时,C开始转(下降)
    {
      pwm1.setPWM(channel, 0, SERVO_30); //C
    }
    Serial.println("第一排");
    delay(interval0);  //0.3s
    for(uint16_t channel=0;channel<=4;channel++)  //T=0.3s时,C转了30度,此时B、D也开始转(下降)
    {
      //pwm2.setPWM(channel, 0, SERVO_30);  //D
      pwm1.setPWM(channel, 0, SERVO_60);  //C
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
       pwm1.setPWM(channel, 0, SERVO_30);  //B
    }
    Serial.println("第二排");
    delay(interval0);  //0.3s
    for(uint16_t channel=10;channel<=12;channel++) //T=0.6s时,C转了60度,B、D转了30度,A、E开始转(下降)
    {
      pwm1.setPWM(channel, 0, SERVO_30);  //A
    }
    for(uint16_t channel=5;channel<=7;channel++)
    {
      //pwm2.setPWM(channel, 0, SERVO_30);  //E
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
      pwm1.setPWM(channel, 0, SERVO_60);  //B
    }
    for(uint16_t channel=0;channel<=4;channel++)  
    {
      //pwm2.setPWM(channel, 0, SERVO_60);  //D
      pwm1.setPWM(channel, 0, SERVO_90);  //C
    }
    Serial.println("第三排");
    delay(interval0);  //0.3s
    for(uint16_t channel=10;channel<=12;channel++)  //T=0.9s时,C转了90度,B、D转了60度,A、E转了30度
    {
      pwm1.setPWM(channel, 0, SERVO_60);  //A
    }
    for(uint16_t channel=5;channel<=7;channel++)
    {
      //pwm2.setPWM(channel, 0, SERVO_60);  //E
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
      pwm1.setPWM(channel, 0, SERVO_90);  //B
    }
    for(uint16_t channel=0;channel<=4;channel++)  
    {
      //pwm2.setPWM(channel, 0, SERVO_90);  //D
      pwm1.setPWM(channel, 0, SERVO_60);  //C
    }
    delay(interval0);  //0.3s
    for(uint16_t channel=10;channel<=12;channel++)  //T=1.2s时,C转回到了60度,B、D转了90度,A、E转了60度
    {
      pwm1.setPWM(channel, 0, SERVO_90);  //A
    }
    for(uint16_t channel=5;channel<=7;channel++)
    {
      //pwm2.setPWM(channel, 0, SERVO_90);  //E
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
      pwm1.setPWM(channel, 0, SERVO_60);  //B
    }
    for(uint16_t channel=0;channel<=4;channel++)  
    {
      //pwm2.setPWM(channel, 0, SERVO_60);  //D
      pwm1.setPWM(channel, 0, SERVO_30);  //C
    }
    delay(interval0);  //0.3s
    for(uint16_t channel=10;channel<=12;channel++)  //T=1.5s时,C转回到了30度,B、D转回了60度,A、E转了90度
    {
      pwm1.setPWM(channel, 0, SERVO_60);  //A
    }                        
    for(uint16_t channel=5;channel<=7;channel++)
    {
      //pwm2.setPWM(channel, 0, SERVO_60);  //E
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
      pwm1.setPWM(channel, 0, SERVO_30);  //B
    }
    for(uint16_t channel=0;channel<=4;channel++)  
    {
      //pwm2.setPWM(channel, 0, SERVO_30);  //D
      pwm1.setPWM(channel, 0, SERVO_0);  //C
    }
    delay(interval0);  //0.3s 
    for(uint16_t channel=10;channel<=12;channel++)  //T=1.8s时,C转回到了0度,B、D转回了30度,A、E转回了60度
    {
      pwm1.setPWM(channel, 0, SERVO_30);  //A
    }
    for(uint16_t channel=5;channel<=7;channel++)
    {
      //pwm2.setPWM(channel, 0, SERVO_30);  //E
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
      pwm1.setPWM(channel, 0, SERVO_0);  //B
    }
    for(uint16_t channel=0;channel<=4;channel++)  
    {
      //pwm2.setPWM(channel, 0, SERVO_0);  //D
      pwm1.setPWM(channel, 0, SERVO_0);  //C
    }
    delay(interval0);  //0.3s                 
    for(uint16_t channel=10;channel<=12;channel++)  //T=2.1s时,C不变,B、D转回了0度,A、E转回了30度
    {
      pwm1.setPWM(channel, 0, SERVO_0);  //A
    }
    for(uint16_t channel=5;channel<=7;channel++)
    {
      //pwm2.setPWM(channel, 0, SERVO_0);  //E
    }
    for(uint16_t channel=5;channel<=9;channel++)  
    {
      pwm1.setPWM(channel, 0, SERVO_0);  //B
    }
    for(uint16_t channel=0;channel<=4;channel++)  
    {
      //pwm2.setPWM(channel, 0, SERVO_0);  //D
      pwm1.setPWM(channel, 0, SERVO_0);  //C
    }                                                                                      
    Serial.println("运动完成");
  }
  else  //TDS大于250
  {
    /*
      *假设1、8、12分别记为A、B、C
    */
    //T=0s时,A开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//A
    Serial.println("第一圈");
    delay(interval0);  //0.3s     //T=0.3s时,A转了30度,此时B也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(8, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
    //pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_60);//A
    Serial.println("第二圈");
    delay(interval0);  //0.3s     //T=0.6s时,A转了60度,B转了30度,C开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);
    //pwm2.setPWM(5, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_90);//A
    Serial.println("第三圈");
    delay(interval0);  //0.3s     //T=0.9s时,A转了90度,B转了60度,C转了30度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    //pwm2.setPWM(4, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    //pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//B
    pwm1.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(8, 0, SERVO_90);
    //pwm2.setPWM(1, 0, SERVO_90);
    //pwm2.setPWM(2, 0, SERVO_90);
    //pwm2.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_60);//A
    delay(interval0);  //0.3s     //T=1.2s时,A转回到了60度,B转了90度,C转了60度
    pwm1.setPWM(0, 0, SERVO_90);//C
    pwm1.setPWM(4, 0, SERVO_90);
    pwm1.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(9, 0, SERVO_90);
    pwm1.setPWM(10, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    pwm1.setPWM(12, 0, SERVO_90);
    //pwm2.setPWM(0, 0, SERVO_90);
    //pwm2.setPWM(4, 0, SERVO_90);
    //pwm2.setPWM(5, 0, SERVO_90);
    //pwm2.setPWM(6, 0, SERVO_90);
    //pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_30);//A
    delay(interval0);  //0.3s     //T=1.5s时,A转回到了30度,B转回了60度,C转了90度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    //pwm2.setPWM(4, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    //pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(8, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
    //pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=1.8s时,A转回到了0度,B转回了30度,C转回了60度
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);
    //pwm2.setPWM(5, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
    //pwm2.setPWM(1, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=2.1s时,A不变,B转回了0度,C转回了30度
    pwm1.setPWM(0, 0, SERVO_0);//C
    pwm1.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(9, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
    //pwm2.setPWM(0, 0, SERVO_0);
    //pwm2.setPWM(4, 0, SERVO_0);
    //pwm2.setPWM(5, 0, SERVO_0);
    //pwm2.setPWM(6, 0, SERVO_0);
    //pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
    //pwm2.setPWM(1, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A
    //delay(interval0);  //0.3s 
    //T=2.4s时,A不变,B不变,C转回了0度                                                                     
    Serial.println("运动完成"); 
  }
  flag=true; 
}

void Draw_VerLine() //画竖线
{
  flag=false;
  if(tdsValue <= 250)
  {
     /*
      *假设3、5、5、5、3分别记为A、B、C、D、E
    */
    //T=0s时,C开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//C
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    //pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    Serial.println("第一排");
    delay(interval0);  //0.3s
    //T=0.3s时,C转了30度,此时B、D也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
    //pwm2.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(3, 0, SERVO_30);//D
    pwm1.setPWM(8, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
    //pwm2.setPWM(3, 0, SERVO_30);
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_60);//C
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    Serial.println("第二排");
    delay(interval0);  //0.3s
    //T=0.6s时,C转了60度,B、D转了30度,A、E开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//A
    pwm1.setPWM(5, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    pwm1.setPWM(4, 0, SERVO_30);//E
    pwm1.setPWM(9, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(3, 0, SERVO_60);//D
    pwm1.setPWM(8, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(3, 0, SERVO_60);
    //pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_90);//C
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    //pwm2.setPWM(2, 0, SERVO_90);
    //pwm2.setPWM(6, 0, SERVO_90);
    Serial.println("第三排");
    delay(interval0);  //0.3s
    //T=0.9s时,C转了90度,B、D转了60度,A、E转了30度
    pwm1.setPWM(0, 0, SERVO_60);//A
    pwm1.setPWM(5, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    pwm1.setPWM(4, 0, SERVO_60);//E
    pwm1.setPWM(9, 0, SERVO_60);
    //pwm2.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//B
    pwm1.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(10, 0, SERVO_90);
    //pwm2.setPWM(1, 0, SERVO_90);
    //pwm2.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(3, 0, SERVO_90);//D
    pwm1.setPWM(8, 0, SERVO_90);
    pwm1.setPWM(12, 0, SERVO_90);
    //pwm2.setPWM(3, 0, SERVO_90);
    //pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_60);//C
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    delay(interval0);  //0.3s
    //T=1.2s时,C转回到了60度,B、D转了90度,A、E转了60度
    pwm1.setPWM(0, 0, SERVO_90);//A
    pwm1.setPWM(5, 0, SERVO_90);
    //pwm2.setPWM(0, 0, SERVO_90);
    pwm1.setPWM(4, 0, SERVO_90);//E
    pwm1.setPWM(9, 0, SERVO_90);
    //pwm2.setPWM(4, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(3, 0, SERVO_60);//D
    pwm1.setPWM(8, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(3, 0, SERVO_60);
    //pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_30);//C
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    //pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    delay(interval0);  //0.3s
    //T=1.5s时,C转回到了30度,B、D转回了60度,A、E转了90度
    pwm1.setPWM(0, 0, SERVO_60);//A
    pwm1.setPWM(5, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    pwm1.setPWM(4, 0, SERVO_60);//E
    pwm1.setPWM(9, 0, SERVO_60);
    //pwm2.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
   // pwm2.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(3, 0, SERVO_30);//D
    pwm1.setPWM(8, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
   //pwm2.setPWM(3, 0, SERVO_30);
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_0);//C
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(6, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=1.8s时,C转回到了0度,B、D转回了30度,A、E转回了60度
    pwm1.setPWM(0, 0, SERVO_30);//A
    pwm1.setPWM(5, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    pwm1.setPWM(4, 0, SERVO_30);//E
    pwm1.setPWM(9, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
    //pwm2.setPWM(1, 0, SERVO_0);
    //pwm2.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//D
    pwm1.setPWM(8, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
    //pwm2.setPWM(3, 0, SERVO_0);
    //pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//C
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(6, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=2.1s时,C不变,B、D转回了0度,A、E转回了30度
    pwm1.setPWM(0, 0, SERVO_0);//A
    pwm1.setPWM(5, 0, SERVO_0);
    //pwm2.setPWM(0, 0, SERVO_0);
    pwm1.setPWM(4, 0, SERVO_0);//E
    pwm1.setPWM(9, 0, SERVO_0);
    //pwm2.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
    //pwm2.setPWM(1, 0, SERVO_0);
    //pwm2.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//D
    pwm1.setPWM(8, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
    //pwm2.setPWM(3, 0, SERVO_0);
    //pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//C
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(6, 0, SERVO_0);  
    Serial.println("运动完成");
  }
  else  //TDS大于250
  {
    /*
      *假设1、8、12分别记为A、B、C
    */
    //T=0s时,A开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//A
    Serial.println("第一圈");
    delay(interval0);  //0.3s     //T=0.3s时,A转了30度,此时B也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    //pwm2.setPWM(8, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
    //pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_60);//A
    Serial.println("第二圈");
    delay(interval0);  //0.3s     //T=0.6s时,A转了60度,B转了30度,C开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);
    //pwm2.setPWM(5, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_90);//A
    Serial.println("第三圈");
    delay(interval0);  //0.3s     //T=0.9s时,A转了90度,B转了60度,C转了30度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    //pwm2.setPWM(4, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    //pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//B
    pwm1.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(8, 0, SERVO_90);
    //pwm2.setPWM(1, 0, SERVO_90);
    //pwm2.setPWM(2, 0, SERVO_90);
    //pwm2.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_60);//A
    delay(interval0);  //0.3s     //T=1.2s时,A转回到了60度,B转了90度,C转了60度
    pwm1.setPWM(0, 0, SERVO_90);//C
    pwm1.setPWM(4, 0, SERVO_90);
    pwm1.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(9, 0, SERVO_90);
    pwm1.setPWM(10, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    pwm1.setPWM(12, 0, SERVO_90);
    //pwm2.setPWM(0, 0, SERVO_90);
    //pwm2.setPWM(4, 0, SERVO_90);
    //pwm2.setPWM(5, 0, SERVO_90);
    //pwm2.setPWM(6, 0, SERVO_90);
    //pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_30);//A
    delay(interval0);  //0.3s     //T=1.5s时,A转回到了30度,B转回了60度,C转了90度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    //pwm2.setPWM(4, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    //pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(8, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
    //pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=1.8s时,A转回到了0度,B转回了30度,C转回了60度
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);
    //pwm2.setPWM(5, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
    //pwm2.setPWM(1, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=2.1s时,A不变,B转回了0度,C转回了30度
    pwm1.setPWM(0, 0, SERVO_0);//C
    pwm1.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(9, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
    //pwm2.setPWM(0, 0, SERVO_0);
    //pwm2.setPWM(4, 0, SERVO_0);
    //pwm2.setPWM(5, 0, SERVO_0);
    //pwm2.setPWM(6, 0, SERVO_0);
    //pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
    //pwm2.setPWM(1, 0, SERVO_0);
    //pwm2.setPWM(2, 0, SERVO_0);
    //pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A                                                                    
    Serial.println("运动完成");  
  }
  flag=true;
}

void Draw_LeftLine()  //画左斜线
{
  flag=false;
  if(tdsValue <= 250)
  {
    /*
     *假设2、3、4、3、4、3、2分别记为A、B、C、D、E、F、G
    */
    //T=0s时,D开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//D
    pwm1.setPWM(8, 0, SERVO_30);
    //pwm2.setPWM(1, 0, SERVO_30);
    Serial.println("第一排");
    delay(interval0);  //0.3s
    //T=0.3s时,D转到了30度,此时C、E也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//C
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
    //pwm2.setPWM(0, 0, SERVO_30);
    pwm1.setPWM(3, 0, SERVO_30);//E
    pwm1.setPWM(9, 0, SERVO_30);
   // pwm2.setPWM(2, 0, SERVO_30);
    //pwm2.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_60);//D
    pwm1.setPWM(8, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    Serial.println("第二排");
    delay(interval0);  //0.3s
    //T=0.6s时,D转了60度,C、E转到了30度,B、F开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//B
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(4, 0, SERVO_30);//F
    //pwm2.setPWM(3, 0, SERVO_30);
    //pwm2.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//C
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
    //pwm2.setPWM(0, 0, SERVO_60);
    pwm1.setPWM(3, 0, SERVO_60);//E
    pwm1.setPWM(9, 0, SERVO_60);
    //pwm2.setPWM(2, 0, SERVO_60);
    //pwm2.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_90);//D
    pwm1.setPWM(8, 0, SERVO_90);
    //pwm2.setPWM(1, 0, SERVO_90);
    Serial.println("第三排");
    delay(interval0);  //0.3s
    //T=0.9s时,D转了90度,C、E转到了60度,B、F转到了30度,A、G开始转(下降)
    pwm1.setPWM(5, 0, SERVO_30);//A
    pwm1.setPWM(10, 0, SERVO_30);
    //pwm2.setPWM(4, 0, SERVO_30);//G
    //pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(0, 0, SERVO_60);//B
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(4, 0, SERVO_60);//F
    //pwm2.setPWM(3, 0, SERVO_60);
    //pwm2.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//C
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(12, 0, SERVO_90);
    //pwm2.setPWM(0, 0, SERVO_90);
    pwm1.setPWM(3, 0, SERVO_90);//E
    pwm1.setPWM(9, 0, SERVO_90);
    //pwm2.setPWM(2, 0, SERVO_90);
    //pwm2.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_60);//D
    pwm1.setPWM(8, 0, SERVO_60);
    //pwm2.setPWM(1, 0, SERVO_60);
    Serial.println("第四排");
    delay(interval0);  //0.3s
    //T=1.2s时,D转回到了60度,C、E转到了90度,B、F转到了60度,A、G转到了30度
    pwm1.setPWM(5, 0, SERVO_60);//A
    pwm1.setPWM(10, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_60);//G
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(0, 0, SERVO_90);//B
    pwm1.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    pwm1.setPWM(4, 0, SERVO_90);//F
//    pwm2.setPWM(3, 0, SERVO_90);
//    pwm2.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//C
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
//    pwm2.setPWM(0, 0, SERVO_60);
    pwm1.setPWM(3, 0, SERVO_60);//E
    pwm1.setPWM(9, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_30);//D
    pwm1.setPWM(8, 0, SERVO_30);
//    pwm2.setPWM(1, 0, SERVO_30);
    delay(interval0);  //0.3s
    //T=1.5s时,D转回到了30度,C、E转回了60度,B、F转了90度,A、G转到了60度
    pwm1.setPWM(5, 0, SERVO_90);//A
    pwm1.setPWM(10, 0, SERVO_90);
//    pwm2.setPWM(4, 0, SERVO_90);//G
//    pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(0, 0, SERVO_60);//B
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(4, 0, SERVO_60);//F
//    pwm2.setPWM(3, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//C
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
//    pwm2.setPWM(0, 0, SERVO_30);
    pwm1.setPWM(3, 0, SERVO_30);//E
    pwm1.setPWM(9, 0, SERVO_30);
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=1.8s时,D转回到了0度,C、E转回了30度,B、F转回了60度,A、G转到了90度
    pwm1.setPWM(5, 0, SERVO_60);//A
    pwm1.setPWM(10, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_60);//G
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(0, 0, SERVO_30);//B
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(4, 0, SERVO_30);//F
//    pwm2.setPWM(3, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//C
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
//    pwm2.setPWM(0, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//E
    pwm1.setPWM(9, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=2.1s时,D不变,C、E转回了0度,B、F转回了30度,A、G转到了60度
    pwm1.setPWM(5, 0, SERVO_30);//A
    pwm1.setPWM(10, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_30);//G
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(0, 0, SERVO_0);//B
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(4, 0, SERVO_0);//F
//    pwm2.setPWM(3, 0, SERVO_0);
//    pwm2.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//C
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
//    pwm2.setPWM(0, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//E
    pwm1.setPWM(9, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=2.4s时,D不变,C、E不变,B、F转回了0度,A、G转到了30度 
    pwm1.setPWM(5, 0, SERVO_0);//A
    pwm1.setPWM(10, 0, SERVO_0);
//    pwm2.setPWM(4, 0, SERVO_0);//G
//    pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(0, 0, SERVO_0);//B
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(4, 0, SERVO_0);//F
//    pwm2.setPWM(3, 0, SERVO_0);
//    pwm2.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//C
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
//    pwm2.setPWM(0, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//E
    pwm1.setPWM(9, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);  
    Serial.println("运动完成");
  }
  else  //TDS大于250
  {
    /*
      *假设1、8、12分别记为A、B、C
    */
    //T=0s时,A开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//A
    Serial.println("第一圈");
    delay(interval0);  //0.3s     //T=0.3s时,A转了30度,此时B也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
//    pwm2.setPWM(8, 0, SERVO_30);
//    pwm2.setPWM(1, 0, SERVO_30);
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_60);//A
    Serial.println("第二圈");
    delay(interval0);  //0.3s     //T=0.6s时,A转了60度,B转了30度,C开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
//    pwm2.setPWM(0, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_30);
//    pwm2.setPWM(5, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
//    pwm2.setPWM(1, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_90);//A
    Serial.println("第三圈");
    delay(interval0);  //0.3s     //T=0.9s时,A转了90度,B转了60度,C转了30度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
//    pwm2.setPWM(0, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_60);
//    pwm2.setPWM(5, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//B
    pwm1.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(8, 0, SERVO_90);
//    pwm2.setPWM(1, 0, SERVO_90);
//    pwm2.setPWM(2, 0, SERVO_90);
//    pwm2.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_60);//A
    delay(interval0);  //0.3s     //T=1.2s时,A转回到了60度,B转了90度,C转了60度
    pwm1.setPWM(0, 0, SERVO_90);//C
    pwm1.setPWM(4, 0, SERVO_90);
    pwm1.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(9, 0, SERVO_90);
    pwm1.setPWM(10, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    pwm1.setPWM(12, 0, SERVO_90);
//    pwm2.setPWM(0, 0, SERVO_90);
//    pwm2.setPWM(4, 0, SERVO_90);
//    pwm2.setPWM(5, 0, SERVO_90);
//    pwm2.setPWM(6, 0, SERVO_90);
//    pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
//    pwm2.setPWM(1, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_30);//A
    delay(interval0);  //0.3s     //T=1.5s时,A转回到了30度,B转回了60度,C转了90度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
//    pwm2.setPWM(0, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_60);
//    pwm2.setPWM(5, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(8, 0, SERVO_30);
//    pwm2.setPWM(1, 0, SERVO_30);
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=1.8s时,A转回到了0度,B转回了30度,C转回了60度
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
//    pwm2.setPWM(0, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_30);
//    pwm2.setPWM(5, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=2.1s时,A不变,B转回了0度,C转回了30度
    pwm1.setPWM(0, 0, SERVO_0);//C
    pwm1.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(9, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
//    pwm2.setPWM(0, 0, SERVO_0);
//    pwm2.setPWM(4, 0, SERVO_0);
//    pwm2.setPWM(5, 0, SERVO_0);
//    pwm2.setPWM(6, 0, SERVO_0);
//    pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A                                                                   
    Serial.println("运动完成");  
  }
  flag=true;
}

void Draw_RightLine() //画右斜线
{
  flag=false;
  if(tdsValue <= 250)
  {
    /*
     *假设2、3、4、3、4、3、2分别记为A、B、C、D、E、F、G
    */
    //T=0s时,D开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//D
    pwm1.setPWM(6, 0, SERVO_30);
//    pwm2.setPWM(3, 0, SERVO_30);
    Serial.println("第一排");
    delay(interval0);  //0.3s 
    //T=0.3s时,D转到了30度,此时C、E也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//C
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(3, 0, SERVO_30);//E
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_60);//D
    pwm1.setPWM(6, 0, SERVO_60);
//    pwm2.setPWM(3, 0, SERVO_60);
    Serial.println("第二排");
    delay(interval0);  //0.3s 
    //T=0.6s时,D转了60度,C、E转到了30度,B、F开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//B
//    pwm2.setPWM(1, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(4, 0, SERVO_30);//F
    pwm1.setPWM(8, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//C
    pwm1.setPWM(5, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(3, 0, SERVO_60);//E
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_90);//D
    pwm1.setPWM(6, 0, SERVO_90);
//    pwm2.setPWM(3, 0, SERVO_90);
    Serial.println("第三排");
    delay(interval0);  //0.3s 
    //T=0.9s时,D转了90度,C、E转到了60度,B、F转到了30度,A、G开始转(下降)
//    pwm2.setPWM(0, 0, SERVO_30);//A
//    pwm2.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);//G
    pwm1.setPWM(12, 0, SERVO_30);
    pwm1.setPWM(0, 0, SERVO_60);//B
//    pwm2.setPWM(1, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(4, 0, SERVO_60);//F
    pwm1.setPWM(8, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//C
    pwm1.setPWM(5, 0, SERVO_90);
//    pwm2.setPWM(2, 0, SERVO_90);
//    pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(3, 0, SERVO_90);//E
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(10, 0, SERVO_90);
//    pwm2.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_60);//D
    pwm1.setPWM(6, 0, SERVO_60);
//    pwm2.setPWM(3, 0, SERVO_60);
    Serial.println("第四排");
    delay(interval0);  //0.3s 
    //T=1.2s时,D转回到了60度,C、E转到了90度,B、F转到了60度,A、G转到了30度
//    pwm2.setPWM(0, 0, SERVO_60);//A
//    pwm2.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);//G
    pwm1.setPWM(12, 0, SERVO_60);
    pwm1.setPWM(0, 0, SERVO_90);//B
//    pwm2.setPWM(1, 0, SERVO_90);
//    pwm2.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(4, 0, SERVO_90);//F
    pwm1.setPWM(8, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//C
    pwm1.setPWM(5, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(3, 0, SERVO_60);//E
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_30);//D
    pwm1.setPWM(6, 0, SERVO_30);
//    pwm2.setPWM(3, 0, SERVO_30);
    delay(interval0);  //0.3s 
    //T=1.5s时,D转回到了30度,C、E转回了60度,B、F转了90度,A、G转到了60度
//    pwm2.setPWM(0, 0, SERVO_90);//A
//    pwm2.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(9, 0, SERVO_90);//G
    pwm1.setPWM(12, 0, SERVO_90);
    pwm1.setPWM(0, 0, SERVO_60);//B
//    pwm2.setPWM(1, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(4, 0, SERVO_60);//F
    pwm1.setPWM(8, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//C
    pwm1.setPWM(5, 0, SERVO_30);
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(3, 0, SERVO_30);//E
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(6, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    delay(interval0);  //0.3s 
    //T=1.8s时,D转回到了0度,C、E转回了30度,B、F转回了60度,A、G转到了90度
//    pwm2.setPWM(0, 0, SERVO_60);//A
//    pwm2.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);//G
    pwm1.setPWM(12, 0, SERVO_60);
    pwm1.setPWM(0, 0, SERVO_30);//B
//    pwm2.setPWM(1, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(4, 0, SERVO_30);//F
    pwm1.setPWM(8, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//C
    pwm1.setPWM(5, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//E
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
//    pwm2.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(6, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=2.1s时,D不变,C、E转回了0度,B、F转回了30度,A、G转到了60度
//    pwm2.setPWM(0, 0, SERVO_30);//A
//    pwm2.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);//G
    pwm1.setPWM(12, 0, SERVO_30);
    pwm1.setPWM(0, 0, SERVO_0);//B
//    pwm2.setPWM(1, 0, SERVO_0);
//    pwm2.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(4, 0, SERVO_0);//F
    pwm1.setPWM(8, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//C
    pwm1.setPWM(5, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//E
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
//    pwm2.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(6, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    delay(interval0);  //0.3s
    //T=2.4s时,D不变,C、E不变,B、F转回了0度,A、G转到了30度 
//    pwm2.setPWM(0, 0, SERVO_0);//A
//    pwm2.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(9, 0, SERVO_0);//G
    pwm1.setPWM(12, 0, SERVO_0);
    pwm1.setPWM(0, 0, SERVO_0);//B
//    pwm2.setPWM(1, 0, SERVO_0);
//    pwm2.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(4, 0, SERVO_0);//F
    pwm1.setPWM(8, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//C
    pwm1.setPWM(5, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(3, 0, SERVO_0);//E
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
//    pwm2.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//D
    pwm1.setPWM(6, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    Serial.println("运动完成");
  }
  else  //TDS大于250
  {
    /*
      *假设1、8、12分别记为A、B、C
    */
    //T=0s时,A开始转(下降)
    pwm1.setPWM(2, 0, SERVO_30);//A
    Serial.println("第一圈");
    delay(interval0);  //0.3s     //T=0.3s时,A转了30度,此时B也开始转(下降)
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
//    pwm2.setPWM(8, 0, SERVO_30);
//    pwm2.setPWM(1, 0, SERVO_30);
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_60);//A
    Serial.println("第二圈");
    delay(interval0);  //0.3s     //T=0.6s时,A转了60度,B转了30度,C开始转(下降)
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
//    pwm2.setPWM(0, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_30);
//    pwm2.setPWM(5, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
//    pwm2.setPWM(1, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_90);//A
    Serial.println("第三圈");
    delay(interval0);  //0.3s     //T=0.9s时,A转了90度,B转了60度,C转了30度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
//    pwm2.setPWM(0, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_60);
//    pwm2.setPWM(5, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_90);//B
    pwm1.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(6, 0, SERVO_90);
    pwm1.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(8, 0, SERVO_90);
//    pwm2.setPWM(1, 0, SERVO_90);
//    pwm2.setPWM(2, 0, SERVO_90);
//    pwm2.setPWM(3, 0, SERVO_90);
    pwm1.setPWM(2, 0, SERVO_60);//A
    delay(interval0);  //0.3s     //T=1.2s时,A转回到了60度,B转了90度,C转了60度
    pwm1.setPWM(0, 0, SERVO_90);//C
    pwm1.setPWM(4, 0, SERVO_90);
    pwm1.setPWM(5, 0, SERVO_90);
    pwm1.setPWM(9, 0, SERVO_90);
    pwm1.setPWM(10, 0, SERVO_90);
    pwm1.setPWM(11, 0, SERVO_90);
    pwm1.setPWM(12, 0, SERVO_90);
//    pwm2.setPWM(0, 0, SERVO_90);
//    pwm2.setPWM(4, 0, SERVO_90);
//    pwm2.setPWM(5, 0, SERVO_90);
//    pwm2.setPWM(6, 0, SERVO_90);
//    pwm2.setPWM(7, 0, SERVO_90);
    pwm1.setPWM(1, 0, SERVO_60);//B
    pwm1.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(6, 0, SERVO_60);
    pwm1.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(8, 0, SERVO_60);
//    pwm2.setPWM(1, 0, SERVO_60);
//    pwm2.setPWM(2, 0, SERVO_60);
//    pwm2.setPWM(3, 0, SERVO_60);
    pwm1.setPWM(2, 0, SERVO_30);//A
    delay(interval0);  //0.3s     //T=1.5s时,A转回到了30度,B转回了60度,C转了90度
    pwm1.setPWM(0, 0, SERVO_60);//C
    pwm1.setPWM(4, 0, SERVO_60);
    pwm1.setPWM(5, 0, SERVO_60);
    pwm1.setPWM(9, 0, SERVO_60);
    pwm1.setPWM(10, 0, SERVO_60);
    pwm1.setPWM(11, 0, SERVO_60);
    pwm1.setPWM(12, 0, SERVO_60);
//    pwm2.setPWM(0, 0, SERVO_60);
//    pwm2.setPWM(4, 0, SERVO_60);
//    pwm2.setPWM(5, 0, SERVO_60);
//    pwm2.setPWM(6, 0, SERVO_60);
//    pwm2.setPWM(7, 0, SERVO_60);
    pwm1.setPWM(1, 0, SERVO_30);//B
    pwm1.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(6, 0, SERVO_30);
    pwm1.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(8, 0, SERVO_30);
//    pwm2.setPWM(1, 0, SERVO_30);
//    pwm2.setPWM(2, 0, SERVO_30);
//    pwm2.setPWM(3, 0, SERVO_30);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=1.8s时,A转回到了0度,B转回了30度,C转回了60度
    pwm1.setPWM(0, 0, SERVO_30);//C
    pwm1.setPWM(4, 0, SERVO_30);
    pwm1.setPWM(5, 0, SERVO_30);
    pwm1.setPWM(9, 0, SERVO_30);
    pwm1.setPWM(10, 0, SERVO_30);
    pwm1.setPWM(11, 0, SERVO_30);
    pwm1.setPWM(12, 0, SERVO_30);
//    pwm2.setPWM(0, 0, SERVO_30);
//    pwm2.setPWM(4, 0, SERVO_30);
//    pwm2.setPWM(5, 0, SERVO_30);
//    pwm2.setPWM(6, 0, SERVO_30);
//    pwm2.setPWM(7, 0, SERVO_30);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A
    delay(interval0);  //0.3s     //T=2.1s时,A不变,B转回了0度,C转回了30度
    pwm1.setPWM(0, 0, SERVO_0);//C
    pwm1.setPWM(4, 0, SERVO_0);
    pwm1.setPWM(5, 0, SERVO_0);
    pwm1.setPWM(9, 0, SERVO_0);
    pwm1.setPWM(10, 0, SERVO_0);
    pwm1.setPWM(11, 0, SERVO_0);
    pwm1.setPWM(12, 0, SERVO_0);
//    pwm2.setPWM(0, 0, SERVO_0);
//    pwm2.setPWM(4, 0, SERVO_0);
//    pwm2.setPWM(5, 0, SERVO_0);
//    pwm2.setPWM(6, 0, SERVO_0);
//    pwm2.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(1, 0, SERVO_0);//B
    pwm1.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(6, 0, SERVO_0);
    pwm1.setPWM(7, 0, SERVO_0);
    pwm1.setPWM(8, 0, SERVO_0);
//    pwm2.setPWM(1, 0, SERVO_0);
//    pwm2.setPWM(2, 0, SERVO_0);
//    pwm2.setPWM(3, 0, SERVO_0);
    pwm1.setPWM(2, 0, SERVO_0);//A                                                                  
    Serial.println("运动完成");  
  }
  flag=true;
}

2.3 气体传感器 —— 气体检测

2.3.1 功能介绍

在这里插入图片描述
在这里插入图片描述

  • 1、气体芯片的大小约1.5*1.5cm大小,如上图所示,16个圆圈对应16个气体检测通道。气体浓度越大,阻值越大。室内通常情况下就是1M欧姆左右,浓度加大阻值可以去到3M欧姆
  • 2、每个通道外接一个分压电阻,分压电阻和气体芯片直接连接到ADS1256芯片,每个ADS芯片有8个通道,因此需要两片ADS。ADS是24位精度ADC采集芯片
    3、不需要计算具体的气体浓度值,用电压值的形式表示就行。并显示在HMI显示屏
  • 4、当然也需要把数据写入SD内存卡。
  • 5、并预留蓝牙接口,把数据也通过蓝牙实时发送出去。
  • 6、通过锂电池供电,并板载锂电池充电电路。

2.3.2 实物图片

1、1ATmega328p
2、4
ADS1115芯片
3、13.5寸HMI显示屏
4、1
气体芯片
5、1SD卡
6、16
电阻

在这里插入图片描述

2.3.3 视频

演示视频暂时无法上传(需要的可以另外帖子留言

2.3.4 源代码

#include <stdio.h>
#include <SoftwareSerial.h>      //虚拟串口定义  ------LCD串口显示屏
SoftwareSerial mySerial(3, 2);   // RX, TX
unsigned char serialData[5];     // 显示屏接收4个字节数据
bool stringComplete = false;     //显示屏数据是否更新  true已更新  false未更新或者已处理  防止二次处理
enum ADCmcuStu{OneTestStart, OneTestEnd, LineModelStart, LineModelEnd}NowStu; //当前状态  OneTestStart:一键测试按键    OneTestEnd:测试结束   LineModelStart:曲线模式

// ad1115 采集定义
#include <Wire.h>
#include <Adafruit_ADS1015.h> /*ADS1115库定义*/
Adafruit_ADS1115 ads0(0x48);  /*ADS设备地址*/
Adafruit_ADS1115 ads1(0x49);  /*ADS设备地址*/
Adafruit_ADS1115 ads2(0x4A);  /*ADS设备地址*/
Adafruit_ADS1115 ads3(0x4B);  /*ADS设备地址*/

//读取SD卡信息库
#include <SPI.h>       //SD卡用到的SPI库
#include <SD.h>        //SD卡用到的库
#include <SdFat.h>     //SD卡文件读写库
Sd2Card card; 
SdVolume volume;
SdFile root;
File myFile;//文件
const int chipSelect = 4; //SD卡4号位选

//蓝牙模块初始化
SoftwareSerial mySerialHc(6,5); // RX, TX
const int HC_EN=7;              //D7引脚用到蓝牙的使能端   目前为一直拉低默认使能   拉高不使能
const int HC_STU=8;             //蓝牙连接引脚  拉高:蓝牙已连接   拉低:蓝牙未连接
bool stringCompleteHc = false;  // 蓝牙数据是否更新   ture:已更新   false:未更新或者更新完成已处理  防止二次处理



void setup(void) {
  Serial.begin(9600);         //主串口波特率未9600  用来调试
  Serial.println("WelCome");  //主串口输出测试
 
  //ad1115 初始化 ,使用4个ADS1115对象方便操作
  ads0.begin();    //ADS1115模块初始化
  ads1.begin();    //ADS1115模块初始化
  ads2.begin();    //ADS1115模块初始化
  ads3.begin();    //ADS1115模块初始化
  

  mySerial.begin(115200);  //显示屏串口波特率
  NowStu=OneTestEnd;       //初始化测试状态为停止测试


  //蓝牙模块初始化
  mySerialHc.begin(9600);       //模块上电灯快闪,arduino发送指令时需要按住模块上的按键
  pinMode(HC_EN, OUTPUT);       //蓝牙使能
  pinMode(HC_STU, INPUT);       //蓝牙状态灯
  digitalWrite(HC_EN, LOW);     //默认使能
  
  mySerial.listen();            //监听切换,由于使用两个软串口,需要切换监听。
  
}


void loop(void) {
  SerialGeTData();           //显示屏串口接收处理
  SerialScan();              //根据显示屏接受到的数据判断当前状态
     
  while(NowStu==OneTestStart){  //如果为测试状态  
    SerialGeTData();  //显示屏串口接收处理
    SerialScan();     //显示屏串口接收处理
    getAndUpLoad();   //测试显示数据和保存数据到SD卡
  }
}
//备用  本来使用串口中断更为合适  虚拟串口串口中不知为何失效
//void SerialEvent() {
//  while (mySerial.available()) {
//    // get the new byte:
//    mySerial.readBytes(serialData, 4);
//    
//    Serial.write(serialData,4);
//    stringComplete=true;
//  }
//}

//按键扫描程序
void SerialScan(){  
  if (stringComplete) {
  
     stringComplete=false;     //这里标志串口显示屏接收的数据已处理,处理完毕
    if(serialData[0]==0x05){    //显示屏数据定义05开头表示一键测试数据界面
      if(serialData[1]==0x00){  //0x00表示一键测试界面用户按下了开始测试
         serialData[1]=0x0D;   //将第二位设置为0XOD,防止二次处理
         NowStu=OneTestStart;  //将当前状态设置为一键测试状态
      }
      else if(serialData[1]==0xFF){   //暂停测试
         serialData[1]=0x0D;   //将第二位设置为0XOD,防止二次处理
         NowStu=OneTestEnd;    //停止采集
         myFile.close();       //SD卡文件关闭
      }
      else if(serialData[1]==0xEA){   //查询SD卡状态
         serialData[1]=0x0D;   //将第二位设置为0XOD,防止二次处理
        //读取内存卡信息
        if (!card.init(SPI_HALF_SPEED, chipSelect) || !SD.begin(4)) {   //SD卡初始化,判断SD卡是否连接正常
            //无SD卡 
            unsigned char data[26]={0x53,0x44,0x73,0x74,0x75,0x2E,0x74,0x78,0x74,0x3D,0x22,0x4E,0x6F,0x20,0x53,0x44,0x20,0x63,0x61,0x72,0x64,0x22,0xff,0xff,0xff};  //该数据为ASCLL码值
            mySerial.write(data,25);         //在一键测试显示屏上面显示无SD卡  
            Serial.println("sd card no");    //主串口调试输出

        } else {
          if (!volume.init(card)) {      //检查SD卡是否符合FAT16文件格式,不符合无法写入,在一键测试的界面上面显示  提示内容为: Only Support FAT16/FAT32
            unsigned char data[40]={0x53,0x44,0x73,0x74,0x75,0x2E,0x74,0x78,0x74,0x3D,0x22,0x4F,0x6E,0x6C,0x79,0x20,0x53,0x75,0x70,0x70,0x6F,0x72,0x74,0x20,0x46,0x41,0x54,0x31,0x36,0x2F,0x46,0x41,0x54,0x33,0x32,0x22,0xff,0xff,0xff};
            mySerial.write(data,39);    //发送提示文字到一键测试界面
          }
          else{
            myFile = SD.open("READTEST.CSV", FILE_WRITE);  //打开测试文件名称
            //有SD卡
            uint32_t volumesize;
            uint32_t dsnd,dend;
            int i=0,j=0;
            volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
            volumesize *= volume.clusterCount();       // we'll have a lot of clusters
            volumesize /= 2;                           // SD card blocks are always 512 bytes (2 blocks are 1KB)
            volumesize /= 1024;                        // MB
            dsnd=volumesize;                           //SD卡内存
            dend=volumesize;                           //SD卡内存
            while(dsnd!=0){
              i=i+1;
              dsnd=dsnd/10;
            }//计算出内存的位数  比如119MB,位数就为3位
            unsigned char data[50]={0x53,0x44,0x73,0x74,0x75,0x2E,0x74,0x78,0x74,0x3D,0x22,0x53,0x44,0x20,0x43,0x61,0x72,0x64,0x20,0x4F,0x4B,0x20,0x53,0x69,0x7A,0x65,0x3D,0x31,0x31,0x31,0x30,0x4D,0x42,0x22,0xff,0xff,0xff};//SDstu.txt="SD Card OK Size=1110MB"
            while(dend!=0){
              *(data+27+i-j)=dend%10+48;
              j=j+1;
              dend=dend/10;
            }//将内存的位数转换成内存  这里将1110MB每个换成相应的内存值
            mySerial.write(data,50);//将一键测试内存状态SD Card OK Size=1110MB
          }

        }
        
      }
   
    }
     else if(serialData[0]==0xBA){  //0XBA代表蓝牙传输界面
         if  (serialData[1]==0xBA){
             serialData[1]=0x0D;     //将第二位设置为0XOD,防止二次处理
             if (digitalRead(HC_STU) == HIGH) {
               //蓝牙已连接
               unsigned char data[20]={0x74,0x32,0x2E,0x74,0x78,0x74,0x3D,0x22,0x4F,0x6E,0x4C,0x69,0x6E,0x65,0x22,0xff,0xff,0xff};
               mySerial.write(data,18);  //蓝牙连接显示Online
            } else {
               unsigned char data[20]={0x74,0x32,0x2E,0x74,0x78,0x74,0x3D,0x22,0x4F,0x66,0x66,0x4C,0x69,0x6E,0x65,0x22,0xff,0xff,0xff};
               mySerial.write(data,19);  //蓝牙连接显示Offline
            }
          
          }
          else if (serialData[2]==0xAF){  //发送数据到手机APP ,用户点击了发送数据到APP上面
              
             
          }
          
      }
    
    
  }
}

//该函数备用  用来蓝牙发送命令让气体检测系统传数据到APP上面
void HcSerialGeTData(){ 
   while(mySerialHc.available()){
    char ch;
    ch = mySerialHc.read();
    Serial.print(ch); 
    if(ch=='1')
     Serial.print("1"); 
    else if(ch=='0')
     Serial.print("0"); 
    else{
       Serial.println("error cmd");//错误指令不作任何操作并输出error
    } 
     stringComplete=true;
  } // Get response
}
//显示屏串口轮询的方式接收4个数据
void SerialGeTData(){ 
   while (mySerial.available()) {
    // get the new byte:
    mySerial.readBytes(serialData, 4);
    stringComplete=true;
  }
}

//采集并且上传数据
void getAndUpLoad(){

  int16_t adc0, adc1, adc2, adc3;
  int16_t adc4, adc5, adc6, adc7;
  int16_t adc8, adc9, adc10, adc11;
  int16_t adc12, adc13, adc14, adc15;
  //采集16个通道的数据
  adc0 = ads0.readADC_SingleEnded(0);
  delay(1); 
  adc1 = ads0.readADC_SingleEnded(1);
  delay(1);
  adc2 = ads0.readADC_SingleEnded(2);
  delay(1);
  adc3 = ads0.readADC_SingleEnded(3);
  delay(1);

  adc4 = ads1.readADC_SingleEnded(0);
  delay(1);
  adc5 = ads1.readADC_SingleEnded(1);
  delay(1);
  adc6 = ads1.readADC_SingleEnded(2);
  delay(1);
  adc7 = ads1.readADC_SingleEnded(3);
  delay(1);

  adc8 = ads2.readADC_SingleEnded(0);
  delay(1);
  adc9 = ads2.readADC_SingleEnded(1);
  delay(1);
  adc10 = ads2.readADC_SingleEnded(2);
  delay(1);
  adc11 = ads2.readADC_SingleEnded(3);
  delay(1);

  adc12 = ads3.readADC_SingleEnded(0);
  delay(1);
  adc13 = ads3.readADC_SingleEnded(1);
  delay(1);
  adc14 = ads3.readADC_SingleEnded(2);
  delay(1);
  adc15 = ads3.readADC_SingleEnded(3);
  delay(1);
  Serial.print(adc0); 
  Serial.print(adc1); 
  Serial.print(adc2);
  Serial.print(adc3);
  Serial.print(adc4);
  Serial.print(adc5);
  Serial.print(adc6);
  Serial.print(adc7);
  Serial.print(adc8);
  Serial.print(adc9);
  Serial.print(adc10);
  Serial.print(adc11);
  Serial.print(adc12);  Serial.print(" "); 
  Serial.print(adc13); Serial.print(" "); 
  Serial.print(adc14); Serial.print(" "); 
  Serial.println(adc15); Serial.print(" "); 

  DisplayADCData(0x6E,0x30,adc0);  //这里0X6E代表左边8个通道的数据控件ID ,0X30代表左边第一个通道  ,adc0是采集的数据
  DisplayADCData(0x6E,0x31,adc1);  //这里0X6E代表左边8个通道的数据控件ID ,0X31代表左边第二个通道  ,adc1是采集的数据
  DisplayADCData(0x6E,0x32,adc2);  //这里0X6E代表左边8个通道的数据控件ID ,0X32代表左边第三个通道  ,adc2是采集的数据  
  DisplayADCData(0x6E,0x33,adc3);  //这里0X6E代表左边8个通道的数据控件ID ,0X33代表左边第四个通道  ,adc3是采集的数据

  DisplayADCData(0x6E,0x34,adc4);  //这里0X6E代表左边8个通道的数据控件ID ,0X34代表左边第五个通道  ,adc5是采集的数据 
  DisplayADCData(0x6E,0x35,adc5);  //这里0X6E代表左边8个通道的数据控件ID ,0X35代表左边第六个通道  ,adc6是采集的数据 
  DisplayADCData(0x6E,0x36,adc6);  //这里0X6E代表左边8个通道的数据控件ID ,0X36代表左边第七个通道  ,adc7是采集的数据   
  DisplayADCData(0x6E,0x37,adc7);  //这里0X6E代表左边8个通道的数据控件ID ,0X37代表左边第八个通道  ,adc8是采集的数据 

  DisplayADCData(0x6D,0x30,adc8);  //这里0X6D代表右边8个通道的数据控件ID ,0X30代表右边第一个通道  ,adc9是采集的数据   
  DisplayADCData(0x6D,0x31,adc9);  //这里0X6D代表右边8个通道的数据控件ID ,0X31代表右边第二个通道  ,adc10是采集的数据 
  DisplayADCData(0x6D,0x32,adc10); //这里0X6D代表右边8个通道的数据控件ID ,0X32代表右边第三个通道  ,adc11是采集的数据   
  DisplayADCData(0x6D,0x33,adc11); //这里0X6D代表右边8个通道的数据控件ID ,0X33代表右边第四个通道  ,adc12是采集的数据 

  DisplayADCData(0x6D,0x34,adc12); //这里0X6D代表右边8个通道的数据控件ID ,0X34代表右边第五个通道  ,adc13是采集的数据   
  DisplayADCData(0x6D,0x35,adc13); //这里0X6D代表右边8个通道的数据控件ID ,0X34代表右边第六个通道  ,adc14是采集的数据 
  DisplayADCData(0x6D,0x36,adc14); //这里0X6D代表右边8个通道的数据控件ID ,0X34代表右边第七个通道  ,adc15是采集的数据    
  DisplayADCData(0x6D,0x37,adc15); //这里0X6D代表右边8个通道的数据控件ID ,0X34代表右边第八个通道  ,adc16是采集的数据  

  char savedata[200]={};
  String savedataString = "";
  char* p;
  p=savedata;
  sprintf(p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",adc0,adc1,adc2,adc3,adc4,adc5,adc6,adc7,adc8,adc9,adc10,adc11,adc12,adc13,adc14,adc15);//将ADC 采集的数据格式化到savedata数据中
  for(int i=0;i<100;i++){
    savedataString+=*(p+i);
  }//循环将char字符数据转换成String格式
  
  if (myFile) {//如果文件能正确打开,则做一下动作
    myFile.println(savedataString); //写入SD卡数据
    myFile.close();                 //SD卡中文件关闭
  } else {
    // if the file didn't open, print an error:
    myFile.close();                //SD卡中文件关闭          
    myFile = SD.open("READTEST.CSV", FILE_WRITE);  //打开
    myFile.println(savedataString);//写入SD卡READTEST.CSV文件数据
    myFile.close();//写完关闭

  }

}
/*------------------------------------------------------
*  函数名称: DisplayADCData
*  参数 TyID: 0X6E代表左边8个通道  0x6D代表右边8个通道
*  参数 id:  比如0X30 代表显示屏中控件数组
*  参数 adcv :让文本控件显示的数据
*  返回值:无
------------------------------------------------------*/
void DisplayADCData(unsigned char tyid,unsigned char id,int16_t adcv){
  unsigned char data[15]={0x6E,0x30,0x2E,0x76,0x61,0x6C,0x3D}; //显示屏显示基本数据格式
  data[0]=tyid;data[1]=id;
  int len=IntoStrAscill(adcv,data);
  mySerial.write(data,10+len);  //发送数据到显示屏
}
/*------------------------------------------------------
*  函数名称: IntoStrAscill
*  参数 a: 表示int16_t类型的传输数据
*  参数 data: 表示int16_t类型的传输数据转换成显示屏能识别的16进制数据
*  返回值:传输数据的长度
------------------------------------------------------*/
int IntoStrAscill(int16_t a,unsigned char *data){
  int16_t dsnd,dend=0;
  int i=0,j=0;
  dend=a;
  dsnd=a;
 while(dsnd!=0){
    i=i+1;
    dsnd=dsnd/10;
  }
  while(dend!=0){
    *(data+6+i-j)=dend%10+48;
    j=j+1;
    dend=dend/10;
  }
  *(data+7+i)=0xff;
  *(data+8+i)=0xff;
  *(data+9+i)=0xff;
  return i;
}

2.4 气体采集平台

2.4.1 功能介绍

  • 1、CCS811采集CO2的ppm值。
  • 2、MICS6814或4541采集CO、NO2、C2H5OH、H2、NH3、CH4、C3H8、C4H10的ppm值。
  • 3、ppm显示在HMI显示屏。
  • 4、当然也需要把数据写入SD内存卡。
  • 5、并预留蓝牙接口,把数据也通过蓝牙实时发送出去。
  • 6、通过锂电池供电,并板载锂电池充电电路。

2.4.2 实物图片

1、1ATmega328p
2、1
3.5寸HMI显示屏
3、1CCS811芯片
4、1
MICS6814或4541芯片
5、1*SD卡

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.4.3 视频

演示视频暂时无法上传(需要的可以另外帖子留言

2.4.4 源代码

#include <SoftwareSerial.h>                     //虚拟串口定义
#include "Adafruit_CCS811.h"
#include <SPI.h>                                //SD卡用到的SPI库
#include <SD.h>                                 //SD卡用到的库
File myFile;                                    //文件
Adafruit_CCS811 ccs;
SoftwareSerial SerialHMI(2, 3);                 //LCD RX, TX
SoftwareSerial SerialBL(6, 5);                  //蓝牙 RX, TX
unsigned char lcdenddata[3] = {0xff,0xff,0xff};
#define SD_CS     4                             //SD卡4号位选
#define C_WAKE    10
#define PIN_CO    A2
#define PIN_NO2   A0
#define PIN_NH3   A1
#define BL_STU    7                              //蓝牙连接引脚  高:蓝牙已连接   低:蓝牙未连接
//--CO-- RED sensor, continuous power ON, 25°C, 50% RH
float CO_a = 4.367409,    CO_b = -1.184229;     //R² = 0.996355
float H2S_a = 0.000750,   H2S_b = -12.648453;   //R² = 0.996355
//float NH3_a = 0.929592,   NH3_b = -4.581835;    //R² = 0.998526
float C2H5OH_a = 1.581239,C2H5OH_b = -1.588810; //R² = 0.999069
//float H2_a = 1.335670,    H2_b = -1.100056;     //R² = 0.923029
float CH4_a = 4.735701, CH4_b = -4.397849;    //R² = 0.994133
//float C3H8_a = 192.959787,C3H8_b = -1.576081;   //R² = 0.991974
float C4H10_a = 0.000001, C4H10_b = -8.574002;  //R² = 0.993917
//--NO2-- OX sensor, continuous power ON, 25°C, 50% RH
float NO2_a = 0.158508,   NO2_b = 1.003580;     //R² = 0.999567
float NO_a = 0.100458,    NO_b = -6.905034;     //R² = 0.996571
float H2_a = 19.414884,   H2_b = -7.140802;     //R² = 0.998710
//--NH3--NH3 sensor, continuous power ON, 25°C, 50% RH
float NH3_a = 0.597818,   NH3_b = -1.906549;    //R² = 0.997497
//float H2_a = 8.065816,    H2_b = -2.779010;     //R² = 0.964979
//float C2H5OH_a = 0.220619,C2H5OH_a = -2.655544; //R² = 0.983520
float C3H8_a = 9.262341,C3H8_b =-2.756977;    //R² = 0.998483
//float C4H10_a = 503.395368,C4H10_b = -1.920635; //R² = 0.977432

int CO_base,NO2_base,NH3_base;                      //base value in the clean air
float CO2,TVOC,CO,H2S,C2H5OH,CH4,C4H10,NO2,NO,H2,NH3,C3H8;                     //ppm value
void setup() {
  Serial.begin(9600);// initialize serial communications at 9600 bps:
  SerialHMI.begin(9600);  //显示屏串口波特率
  SerialBL.begin(9600);  //显示屏串口波特率
  pinMode(C_WAKE, OUTPUT);
  digitalWrite(C_WAKE, LOW);
  pinMode(BL_STU, INPUT);       //蓝牙状态灯
  if(!ccs.begin()){
    Serial.println(F("Failed to start CO2 sensor! Please check your wiring."));
  }
  // Wait for the sensor to be ready
//  while(!ccs.available());
  ccs.disableInterrupt();
  //清洁空气下的base值,200次取平均
  CO_base = 0;
  NO2_base = 0;
  NH3_base = 0;
  for(int count = 1; count <= 200; count++){
    CO_base += (analogRead(PIN_CO) - CO_base)/count;   //求平均值
    NO2_base += (analogRead(PIN_NO2) - NO2_base)/count;//求平均值
    NH3_base += (analogRead(PIN_NH3) - NH3_base)/count;//求平均值
  }
}

void loop() {
  Gases_read();
  HMIdisplay();
  Bluetooth();
  Serialprint();
  SD_dataLog();
  delay(1000);
}
float Get_ppm(int _Gas_pin, int _Gas_base, float Gas_a, float Gas_b){
  int _Gas_now = analogRead(_Gas_pin);
  if(_Gas_now < _Gas_base) _Gas_now = _Gas_base;
  float _Rs_R0 = ((1023.0 - _Gas_now) * _Gas_base * 1.0)/((1023.0 - _Gas_base) * _Gas_now);// Get ratio RS_gas/RS_air
  if(_Rs_R0 <= 0){ _Rs_R0 = 0;} //No negative values accepted or upper datasheet recomendation.
  float _PPM= Gas_a*pow(_Rs_R0, Gas_b);
  if(_PPM < 0) { _PPM = 0;} //No negative values accepted or upper datasheet recomendation.
  //if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
  return _PPM;
}
void Gases_read(){
  if(ccs.available()){
    if(!ccs.readData()){
      CO2 = ccs.geteCO2();
      if(CO2 < 10){CO2 = random(400,410);}
      TVOC = ccs.getTVOC();
//      tempvalue=ccs.calculateTemperature();
    }
    else{
      Serial.println(F("CCS811 ERROR!"));
    }
  }

  CO = Get_ppm(PIN_CO, CO_base, CO_a, CO_b);              //Carbon monoxide   1 – 1000ppm
  NO2 = Get_ppm(PIN_NO2, NO2_base, NO2_a, NO2_b);         //Nitrogen dioxide 0.05 – 10ppm
  C2H5OH  = Get_ppm(PIN_CO, CO_base, C2H5OH_a, C2H5OH_b); //Ethanol           10 – 500ppm
  H2 = Get_ppm(PIN_NO2, NO2_base, H2_a, H2_b);            //Hydrogen          1 – 1000ppm
  NH3 = Get_ppm(PIN_NH3, NH3_base, NH3_a, NH3_b);         //Ammonia            1 – 500ppm
  CH4 = Get_ppm(PIN_CO, CO_base, CH4_a, CH4_b);           //Methane              >1000ppm
  C3H8 = Get_ppm(PIN_NH3, NH3_base, C3H8_a, C3H8_b);      //Propane              >1000ppm
  C4H10 = Get_ppm(PIN_CO, CO_base, C4H10_a, C4H10_b);     //Iso-butane           >1000ppm
  H2S = Get_ppm(PIN_CO, CO_base, H2S_a, H2S_b);
  NO = Get_ppm(PIN_NO2, NO2_base, NO_a, NO_b);
}
void HMIprint(String ID, uint16_t value){
  SerialHMI.print(ID + value);
  SerialHMI.write(lcdenddata,3);
  delay(10);
}
void HMIdisplay(){
  HMIprint("x0.val=", CO2*100);
  HMIprint("x1.val=", TVOC*100);
  HMIprint("x2.val=", CO*100);
  HMIprint("x3.val=", NO2*100);
  HMIprint("x4.val=", C2H5OH*100);
  HMIprint("x5.val=", H2*100);
  HMIprint("x6.val=", NH3*100);
  HMIprint("x7.val=", CH4*100);
  HMIprint("x8.val=", C3H8*100);
  HMIprint("x9.val=", C4H10*100);
  HMIprint("x10.val=", H2S*100);
  HMIprint("x11.val=", NO*100);
}
/********蓝牙状态函数********/
void Bluetooth(){                    
  int Bluetooth_State = digitalRead(BL_STU);            //读取I/O口状态
  if(Bluetooth_State == HIGH){
    Serial.println(F("Bluetooth Connected")); 
    SerialHMI.print(F("s1.txt="Bluetooth connected""));  
    SerialHMI.write(lcdenddata,3); 
    delay(10);
  }
  else{
    Serial.println(F("Bluetooth available")); 
    SerialHMI.print(F("s1.txt="Bluetooth available""));  
    SerialHMI.write(lcdenddata,3); 
    delay(10);
  }
} 
void SD_dataLog(){
  if (!SD.begin(SD_CS)){ //SD卡初始化,判断SD卡是否连接正常      
    Serial.println(F("SD Not Ready"));  
    SerialHMI.print(F("s2.txt="SD Not Ready"")); 
    SerialHMI.write(lcdenddata,3);  
  }
  else{
    Serial.println(F("SD Ready")); 
    SerialHMI.print(F("s2.txt="SD Ready"")); 
    SerialHMI.write(lcdenddata,3);   
    myFile = SD.open("datalog.CSV", FILE_WRITE);  //打开
    delay(1000);
    myFile.print(CO2);   myFile.print(F(","));
    myFile.print(TVOC);  myFile.print(F(","));
    myFile.print(CO);    myFile.print(F(","));
    myFile.print(NO2);   myFile.print(F(","));
    myFile.print(C2H5OH);myFile.print(F(","));
    myFile.print(H2);    myFile.print(F(","));
    myFile.print(NH3);   myFile.print(F(","));
    myFile.print(CH4);   myFile.print(F(","));
    myFile.print(C3H8);  myFile.print(F(","));
    myFile.print(C4H10); myFile.print(F(","));
    myFile.print(H2S);   myFile.print(F(","));
    myFile.println(NO);
//    myFile.println();
    myFile.close();//写完关闭  
    delay(1000);
  }
}
void Serialprint(){
  Serial.println(F("-----------------------------------------------------")); 
  Serial.print(F("  CO2 :"));Serial.print(CO2);Serial.print(F("tppmt TVOC:"));Serial.print(TVOC);Serial.println(F("tppm")); 
  Serial.print(F("  CO  :"));Serial.print(CO);Serial.print(F("tppmt NO2 :"));Serial.print(NO2);Serial.println(F("tppm")); 
  Serial.print(F("C2H5OH:"));Serial.print(C2H5OH);Serial.print(F("tppmt  H2 :"));Serial.print(H2);Serial.println(F("tppm")); 
  Serial.print(F("  NH3 :"));Serial.print(NH3);Serial.print(F("tppmt CH4 :"));Serial.print(CH4);Serial.println(F("tppm")); 
  Serial.print(F(" C3H8 :"));Serial.print(C3H8);Serial.print(F("tppmtC4H10:"));Serial.print(C4H10);Serial.println(F("tppm")); 
  Serial.print(F("  H2S :"));Serial.print(H2S);Serial.print(F("tppmt  NO :"));Serial.print(NO);Serial.println(F("tppm")); 

  SerialBL.print(F("  CO2 :"));SerialBL.print(CO2);SerialBL.print(F("tppmt TVOC:"));SerialBL.print(TVOC);SerialBL.println(F("tppm")); 
  SerialBL.print(F("  CO  :"));SerialBL.print(CO);SerialBL.print(F("tppmt NO2 :"));SerialBL.print(NO2);SerialBL.println(F("tppm")); 
  SerialBL.print(F("C2H5OH:"));SerialBL.print(C2H5OH);SerialBL.print(F("tppmt  H2 :"));SerialBL.print(H2);SerialBL.println(F("tppm")); 
  SerialBL.print(F("  NH3 :"));SerialBL.print(NH3);SerialBL.print(F("tppmt CH4 :"));SerialBL.print(CH4);SerialBL.println(F("tppm")); 
  SerialBL.print(F(" C3H8 :"));SerialBL.print(C3H8);SerialBL.print(F("tppmtC4H10:"));SerialBL.print(C4H10);SerialBL.println(F("tppm")); 
  SerialBL.print(F("  H2S :"));SerialBL.print(H2S);SerialBL.print(F("tppmt  NO :"));SerialBL.print(NO);SerialBL.println(F("tppm")); 
  
//  Serial.println(String("  CO  :") + CO     + "tppmt NO2 :" + TVOC  + "tppm"); 
//  Serial.println(String("C2H5OH:") + C2H5OH + "tppmt  H2 :" + H2    + "tppm"); 
//  Serial.println(String("  NH3 :") + NH3    + "tppmt CH4 :" + CH4   + "tppm"); 
//  Serial.println(String(" C3H8 :") + C3H8   + "tppmtC4H10:" + C4H10 + "tppm"); 
//  Serial.println(String("  H2S :") + H2S    + "tppmt  NO :" + NO    + "tppm"); 

//  SerialBL.println(String("  CO2 :") + CO2    + "tppmt TVOC:" + TVOC  + "tppm"); 
//  SerialBL.println(String("  CO  :") + CO     + "tppmt NO2 :" + TVOC  + "tppm"); 
//  SerialBL.println(String("C2H5OH:") + C2H5OH + "tppmt  H2 :" + H2    + "tppm"); 
//  SerialBL.println(String("  NH3 :") + NH3    + "tppmt CH4 :" + CH4   + "tppm"); 
//  SerialBL.println(String(" C3H8 :") + C3H8   + "tppmtC4H10:" + C4H10 + "tppm"); 
//  SerialBL.println(String("  H2S :") + H2S    + "tppmt  NO :" + NO    + "tppm"); 
}

3、如何联系我们

博主联系方式汇总(非诚勿扰)

最后

以上就是时尚向日葵为你收集整理的基于Arduino、ESP8266的物联网项目开发方案整理、毕业设计(第二波)的全部内容,希望文章能够帮你解决基于Arduino、ESP8266的物联网项目开发方案整理、毕业设计(第二波)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部