CH3551355 2024-08-16 08:59 采纳率: 0%
浏览 3

什么情况,arduino大老可以邦盲吗


请问arduino这是什么情况

代码如下

#include <Wire.h>

#include <Adafruit_PWMServoDriver.h>

#include <ESP8266WiFi.h>

#include <TimeLib.h>

#include <NtpClientLib.h>

Adafruit_PWMServoDriver pwm0 = Adafruit_PWMServoDriver(0x40);

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x41);

Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x42);



int8_t timeZone = 8;

const PROGMEM char *ntpServer = "ntp1.aliyun.com";



#define SERVOMIN  200

#define SERVOMAX  400

#define USMIN  600

#define USMAX  2400

#define SERVO_FREQ 50



int DateYear = 0;

int DateMonth = 0;

int DateDay = 0;

int DateHour = 0;

int DateMinute = 0;

int DateSecond = 0;



int num1;

int num2;

int num3;

int num4;

int num5;

int num6;



uint8_t servonum = 8;



void SerialPrint(){

  Serial.print(DateHour);

  Serial.print("时");

  Serial.print(DateMinute);

  Serial.print("分");

  Serial.print(DateSecond);

  Serial.println("秒");

}

void setServo(int groups,int num){

  if(groups == 1){

    if(num == 0){

      pwm0.setPWM(0,0,SERVOMIN);

      pwm0.setPWM(1,0,SERVOMIN);

      pwm0.setPWM(2,0,SERVOMAX);

      pwm0.setPWM(3,0,SERVOMAX);

      pwm0.setPWM(4,0,SERVOMAX);

      pwm0.setPWM(5,0,SERVOMIN);

      pwm0.setPWM(6,0,SERVOMIN);

    }

    else if(num == 1){

      pwm0.setPWM(0,0,SERVOMAX);

      pwm0.setPWM(1,0,SERVOMAX);

      pwm0.setPWM(2,0,SERVOMAX);

      pwm0.setPWM(3,0,SERVOMAX);

      pwm0.setPWM(4,0,SERVOMIN);

      pwm0.setPWM(5,0,SERVOMIN);

      pwm0.setPWM(6,0,SERVOMAX);

    }

    else if(num == 2){

      pwm0.setPWM(0,0,SERVOMIN);

      pwm0.setPWM(1,0,SERVOMAX);

      pwm0.setPWM(2,0,SERVOMAX);

      pwm0.setPWM(3,0,SERVOMIN);

      pwm0.setPWM(4,0,SERVOMAX);

      pwm0.setPWM(5,0,SERVOMAX);

      pwm0.setPWM(6,0,SERVOMIN);

    }

    else if(num == 3){

      pwm0.setPWM(0,0,SERVOMIN);

      pwm0.setPWM(1,0,SERVOMAX);

      pwm0.setPWM(2,0,SERVOMAX);

      pwm0.setPWM(3,0,SERVOMIN);

      pwm0.setPWM(4,0,SERVOMIN);

      pwm0.setPWM(5,0,SERVOMIN);

      pwm0.setPWM(6,0,SERVOMIN);

    }

    else if(num == 4){

      pwm0.setPWM(0,0,SERVOMAX);

      pwm0.setPWM(1,0,SERVOMIN);

      pwm0.setPWM(2,0,SERVOMAX);

      pwm0.setPWM(3,0,SERVOMIN);

      pwm0.setPWM(4,0,SERVOMIN);

      pwm0.setPWM(5,0,SERVOMIN);

      pwm0.setPWM(6,0,SERVOMAX);

    }

    else if(num == 5){

      pwm0.setPWM(0,0,SERVOMIN);

      pwm0.setPWM(1,0,SERVOMIN);

      pwm0.setPWM(2,0,SERVOMIN);

      pwm0.setPWM(3,0,SERVOMIN);

      pwm0.setPWM(4,0,SERVOMIN);

      pwm0.setPWM(5,0,SERVOMIN);

      pwm0.setPWM(6,0,SERVOMIN);

    }

    else if(num == 6){

      pwm0.setPWM(0,0,SERVOMIN);

      pwm0.setPWM(1,0,SERVOMIN);

      pwm0.setPWM(2,0,SERVOMIN);

      pwm0.setPWM(3,0,SERVOMIN);

      pwm0.setPWM(4,0,SERVOMAX);

      pwm0.setPWM(5,0,SERVOMIN);

      pwm0.setPWM(6,0,SERVOMIN);

    }

    else if(num == 7){

      pwm0.setPWM(0,0,SERVOMIN);

      pwm0.setPWM(1,0,SERVOMAX);

      pwm0.setPWM(2,0,SERVOMAX);

      pwm0.setPWM(3,0,SERVOMAX);

      pwm0.setPWM(4,0,SERVOMIN);pwm0.setPWM(5,0,SERVOMIN);pwm0.setPWM(6,0,SERVOMAX);

    }

    else if(num == 8){

      pwm0.setPWM(0,0,SERVOMIN);pwm0.setPWM(1,0,SERVOMIN);pwm0.setPWM(2,0,SERVOMAX);pwm0.setPWM(3,0,SERVOMIN);pwm0.setPWM(4,0,SERVOMAX);pwm0.setPWM(5,0,SERVOMIN);pwm0.setPWM(6,0,SERVOMIN);

    }

    else if(num == 9){

      pwm0.setPWM(0,0,SERVOMIN);pwm0.setPWM(1,0,SERVOMIN);pwm0.setPWM(2,0,SERVOMAX);pwm0.setPWM(3,0,SERVOMIN);pwm0.setPWM(4,0,SERVOMIN);pwm0.setPWM(5,0,SERVOMIN);pwm0.setPWM(6,0,SERVOMIN);

    }

  }

  else if(groups == 2){

    if(num == 0){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMIN);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMAX);pwm0.setPWM(4+8,0,SERVOMAX);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

    else if(num == 1){

      pwm0.setPWM(8,0,SERVOMAX);pwm0.setPWM(1+8,0,SERVOMAX);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMAX);pwm0.setPWM(4+8,0,SERVOMIN);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 2){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMAX);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMAX);pwm0.setPWM(5+8,0,SERVOMAX);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

    else if(num == 3){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMAX);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMIN);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

    else if(num == 4){

      pwm0.setPWM(8,0,SERVOMAX);pwm0.setPWM(1+8,0,SERVOMIN);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMIN);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 5){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMIN);pwm0.setPWM(2+8,0,SERVOMIN);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMIN);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

    else if(num == 6){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMIN);pwm0.setPWM(2+8,0,SERVOMIN);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMAX);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

    else if(num == 7){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMAX);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMAX);pwm0.setPWM(4+8,0,SERVOMIN);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 8){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMIN);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMAX);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

    else if(num == 9){

      pwm0.setPWM(8,0,SERVOMIN);pwm0.setPWM(1+8,0,SERVOMIN);pwm0.setPWM(2+8,0,SERVOMAX);pwm0.setPWM(3+8,0,SERVOMIN);pwm0.setPWM(4+8,0,SERVOMIN);pwm0.setPWM(5+8,0,SERVOMIN);pwm0.setPWM(6+8,0,SERVOMIN+20);

    }

  }

  else if(groups == 3){

    if(num == 0){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMIN);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMAX);pwm1.setPWM(4,0,SERVOMAX);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMIN);

    }

    else if(num == 1){

      pwm1.setPWM(0,0,SERVOMAX);pwm1.setPWM(1,0,SERVOMAX);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMAX);pwm1.setPWM(4,0,SERVOMIN);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMAX);

    }

    else if(num == 2){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMAX);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMAX);pwm1.setPWM(5,0,SERVOMAX);pwm1.setPWM(6,0,SERVOMIN);

    }

    else if(num == 3){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMAX);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMIN);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMIN);

    }

    else if(num == 4){

      pwm1.setPWM(0,0,SERVOMAX);pwm1.setPWM(1,0,SERVOMIN);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMIN);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMAX);

    }

    else if(num == 5){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMIN);pwm1.setPWM(2,0,SERVOMIN);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMIN);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMIN);

    }

    else if(num == 6){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMIN);pwm1.setPWM(2,0,SERVOMIN);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMAX);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMIN);

    }

    else if(num == 7){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMAX);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMAX);pwm1.setPWM(4,0,SERVOMIN);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMAX);

    }

    else if(num == 8){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMIN);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMAX);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMIN);

    }

    else if(num == 9){

      pwm1.setPWM(0,0,SERVOMIN);pwm1.setPWM(1,0,SERVOMIN);pwm1.setPWM(2,0,SERVOMAX);pwm1.setPWM(3,0,SERVOMIN);pwm1.setPWM(4,0,SERVOMIN);pwm1.setPWM(5,0,SERVOMIN);pwm1.setPWM(6,0,SERVOMIN);

    }

  }

  else if(groups == 4){

    if(num == 0){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMIN);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMAX);pwm1.setPWM(4+8,0,SERVOMAX);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 1){

      pwm1.setPWM(8,0,SERVOMAX);pwm1.setPWM(1+8,0,SERVOMAX);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMAX);pwm1.setPWM(4+8,0,SERVOMIN);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 2){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMAX);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMAX);pwm1.setPWM(5+8,0,SERVOMAX);pwm1.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 3){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMAX);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMIN);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 4){

      pwm1.setPWM(8,0,SERVOMAX);pwm1.setPWM(1+8,0,SERVOMIN);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMIN);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 5){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMIN);pwm1.setPWM(2+8,0,SERVOMIN);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMIN);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 6){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMIN);pwm1.setPWM(2+8,0,SERVOMIN);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMAX);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 7){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMAX);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMAX);pwm1.setPWM(4+8,0,SERVOMIN);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 8){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMIN);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMAX);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 9){

      pwm1.setPWM(8,0,SERVOMIN);pwm1.setPWM(1+8,0,SERVOMIN);pwm1.setPWM(2+8,0,SERVOMAX);pwm1.setPWM(3+8,0,SERVOMIN);pwm1.setPWM(4+8,0,SERVOMIN);pwm1.setPWM(5+8,0,SERVOMIN);pwm1.setPWM(6+8,0,SERVOMIN);

    }

  }

  else if(groups == 5){

    if(num == 0){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMIN);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMAX);pwm2.setPWM(4,0,SERVOMAX);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMIN);

    }

    else if(num == 1){

      pwm2.setPWM(0,0,SERVOMAX);pwm2.setPWM(1,0,SERVOMAX);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMAX);pwm2.setPWM(4,0,SERVOMIN);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMAX);

    }

    else if(num == 2){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMAX);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMAX);pwm2.setPWM(5,0,SERVOMAX);pwm2.setPWM(6,0,SERVOMIN);

    }

    else if(num == 3){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMAX);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMIN);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMIN);

    }

    else if(num == 4){

      pwm2.setPWM(0,0,SERVOMAX);pwm2.setPWM(1,0,SERVOMIN);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMIN);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMAX);

    }

    else if(num == 5){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMIN);pwm2.setPWM(2,0,SERVOMIN);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMIN);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMIN);

    }

    else if(num == 6){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMIN);pwm2.setPWM(2,0,SERVOMIN);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMAX);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMIN);

    }

    else if(num == 7){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMAX);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMAX);pwm2.setPWM(4,0,SERVOMIN);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMAX);

    }

    else if(num == 8){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMIN);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMAX);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMIN);

    }

    else if(num == 9){

      pwm2.setPWM(0,0,SERVOMIN);pwm2.setPWM(1,0,SERVOMIN);pwm2.setPWM(2,0,SERVOMAX);pwm2.setPWM(3,0,SERVOMIN);pwm2.setPWM(4,0,SERVOMIN);pwm2.setPWM(5,0,SERVOMIN);pwm2.setPWM(6,0,SERVOMIN);

    }

  }

  else if(groups == 6){

    if(num == 0){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMIN);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMAX);pwm2.setPWM(4+8,0,SERVOMAX);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 1){

      pwm2.setPWM(8,0,SERVOMAX);pwm2.setPWM(1+8,0,SERVOMAX);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMAX);pwm2.setPWM(4+8,0,SERVOMIN);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 2){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMAX);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMAX);pwm2.setPWM(5+8,0,SERVOMAX);pwm2.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 3){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMAX);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMIN);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 4){

      pwm2.setPWM(8,0,SERVOMAX);pwm2.setPWM(1+8,0,SERVOMIN);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMIN);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 5){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMIN);pwm2.setPWM(2+8,0,SERVOMIN);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMIN);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMIN);

   

    }

    else if(num == 6){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMIN);pwm2.setPWM(2+8,0,SERVOMIN);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMAX);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 7){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMAX);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMAX);pwm2.setPWM(4+8,0,SERVOMIN);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMAX);

    }

    else if(num == 8){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMIN);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMAX);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMIN);

    }

    else if(num == 9){

      pwm2.setPWM(8,0,SERVOMIN);pwm2.setPWM(1+8,0,SERVOMIN);pwm2.setPWM(2+8,0,SERVOMAX);pwm2.setPWM(3+8,0,SERVOMIN);pwm2.setPWM(4+8,0,SERVOMIN);pwm2.setPWM(5+8,0,SERVOMIN);pwm2.setPWM(6+8,0,SERVOMIN);

    }

  }

}



void setup() {

  Serial.begin(9600);

  Serial.println("Hello world!");

  pwm0.begin();

  pwm1.begin();

  pwm2.begin();

  pwm0.setOscillatorFrequency(27000000);

  pwm1.setOscillatorFrequency(27000000);

  pwm2.setOscillatorFrequency(27000000);

  pwm0.setPWMFreq(SERVO_FREQ);

  pwm1.setPWMFreq(SERVO_FREQ);

  pwm2.setPWMFreq(SERVO_FREQ);

  WiFi.begin("HMQ-5G", "hmq810504");

  while (WiFi.status() != WL_CONNECTED) {

    delay(300);

    Serial.print(".");

  }

  NTP.setInterval (600);

  NTP.setNTPTimeout (1500);

  NTP.begin (ntpServer, timeZone, false);

  Serial.println(WiFi.status());

  Serial.println(WiFi.localIP());

  setServo(1,8);

  delay(500);

  setServo(2,8);

  delay(500);

  setServo(3,8);

  delay(500);

  setServo(4,8);

  delay(500);

  setServo(5,8);

  delay(500);

  setServo(6,8);

  delay(2000);

  DateHour = NTP.getTimeHour24();

  num1 = DateHour / 10;

  num2 = DateHour % 10;

  setServo(1,num1);

  delay(500);

  setServo(2,num2);

  delay(500);

  DateMinute = NTP.getTimeMinute();

  num3 = DateMinute / 10;

  num4 = DateMinute % 10;

  setServo(3,num3);

  delay(500);

  setServo(4,num4);

  delay(500);

  DateSecond = NTP.getTimeSecond();

  num5 = DateSecond / 10;

  num6 = DateSecond % 10;

  setServo(5,num5);

  delay(500);

  setServo(6,num6);

  delay(500);

}



void loop() {



  if(!(DateHour == NTP.getTimeHour24())){

    DateHour = NTP.getTimeHour24();

    num1 = DateHour / 10;

    num2 = DateHour % 10;

    setServo(1,num1);

    setServo(2,num2);

    SerialPrint();

  }



  if(!(DateMinute == NTP.getTimeMinute())){

    DateMinute = NTP.getTimeMinute();

    num3 = DateMinute / 10;

    num4 = DateMinute % 10;

    setServo(3,num3);

    setServo(4,num4);

    SerialPrint();

  }



  if(!(DateSecond == NTP.getTimeSecond())){

    DateSecond = NTP.getTimeSecond();

    num5 = DateSecond / 10;

    num6 = DateSecond % 10;

    setServo(5,num5);

    setServo(6,num6);

    SerialPrint();

  }

}

显示报错

In file included from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:5:
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:79: error: 'byte' has not been declared
  501 |     bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
      |                                                                               ^~~~
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino: In function 'void setup()':
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:319:18: error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:326:20: error: 'class NTPClient' has no member named 'getTimeMinute'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:333:20: error: 'class NTPClient' has no member named 'getTimeSecond'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino: In function 'void loop()':
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:344:24: error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:345:20: error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:353:26: error: 'class NTPClient' has no member named 'getTimeMinute'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:354:22: error: 'class NTPClient' has no member named 'getTimeMinute'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:362:26: error: 'class NTPClient' has no member named 'getTimeSecond'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:363:22: error: 'class NTPClient' has no member named 'getTimeSecond'; did you mean 'getTimeZone'?

exit status 1

Compilation error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?

什么情况安装了以下库文件

  • 写回答

1条回答 默认 最新

  • GISer Liu 2024-08-16 09:01
    关注

    该回答引用自GPT-deepseek, 由博主 GISer Liu 编写:

    根据您提供的代码和报错信息,问题主要集中在 NTPClient 库的使用上。具体来说,报错信息指出 NTPClient 类中没有 getTimeHour24getTimeMinutegetTimeSecond 这些成员函数。这可能是由于您使用的 NTPClientLib 库版本不支持这些函数,或者这些函数的名称有误。

    解决思路

    1. 检查库版本:确保您使用的 NTPClientLib 库是最新版本,或者至少是支持这些函数的版本。
    2. 查找正确的函数名:查阅 NTPClientLib 库的文档,找到正确的函数名来获取小时、分钟和秒。
    3. 修改代码:根据正确的函数名修改代码。

    解决方案

    1. 更新库:首先尝试更新 NTPClientLib 库到最新版本。

      Arduino IDE -> 工具 -> 库管理 -> 搜索 "NtpClientLib" -> 更新
      
    2. 查找正确的函数名:查阅 NTPClientLib 库的文档或示例代码,找到正确的函数名。假设正确的函数名是 getHours()getMinutes()getSeconds()

    3. 修改代码:根据正确的函数名修改代码。

    #include <Wire.h>
    #include <Adafruit_PWMServoDriver.h>
    #include <ESP8266WiFi.h>
    #include <TimeLib.h>
    #include <NtpClientLib.h>
    
    Adafruit_PWMServoDriver pwm0 = Adafruit_PWMServoDriver(0x40);
    Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x41);
    Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x42);
    
    int8_t timeZone = 8;
    const PROGMEM char *ntpServer = "ntp1.aliyun.com";
    
    #define SERVOMIN  200
    #define SERVOMAX  400
    #define USMIN  600
    #define USMAX  2400
    #define SERVO_FREQ 50
    
    int DateYear = 0;
    int DateMonth = 0;
    int DateDay = 0;
    int DateHour = 0;
    int DateMinute = 0;
    int DateSecond = 0;
    
    int num1;
    int num2;
    int num3;
    int num4;
    int num5;
    int num6;
    
    uint8_t servonum = 8;
    
    void SerialPrint(){
      Serial.print(DateHour);
      Serial.print("时");
      Serial.print(DateMinute);
      Serial.print("分");
      Serial.print(DateSecond);
      Serial.println("秒");
    }
    
    void setServo(int groups, int num){
      // 省略具体实现,与原代码相同
    }
    
    void setup() {
      Serial.begin(9600);
      Serial.println("Hello world!");
      pwm0.begin();
      pwm1.begin();
      pwm2.begin();
      pwm0.setOscillatorFrequency(27000000);
      pwm1.setOscillatorFrequency(27000000);
      pwm2.setOscillatorFrequency(27000000);
      pwm0.setPWMFreq(SERVO_FREQ);
      pwm1.setPWMFreq(SERVO_FREQ);
      pwm2.setPWMFreq(SERVO_FREQ);
      WiFi.begin("HMQ-5G", "hmq810504");
      while (WiFi.status() != WL_CONNECTED) {
        delay(300);
        Serial.print(".");
      }
      NTP.setInterval (600);
      NTP.setNTPTimeout (1500);
      NTP.begin (ntpServer, timeZone, false);
      Serial.println(WiFi.status());
      Serial.println(WiFi.localIP());
      setServo(1,8);
      delay(500);
      setServo(2,8);
      delay(500);
      setServo(3,8);
      delay(500);
      setServo(4,8);
      delay(500);
      setServo(5,8);
      delay(500);
      setServo(6,8);
      delay(2000);
      DateHour = NTP.getHours();
      num1 = DateHour / 10;
      num2 = DateHour % 10;
      setServo(1,num1);
      delay(500);
      setServo(2,num2);
      delay(500);
      DateMinute = NTP.getMinutes();
      num3 = DateMinute / 10;
      num4 = DateMinute % 10;
      setServo(3,num3);
      delay(500);
      setServo(4,num4);
      delay(500);
      DateSecond = NTP.getSeconds();
      num5 = DateSecond / 10;
      num6 = DateSecond % 10;
      setServo(5,num5);
      delay(500);
      setServo(6,num6);
      delay(500);
    }
    
    void loop() {
      if(!(DateHour == NTP.getHours())){
        DateHour = NTP.getHours();
        num1 = DateHour / 10;
        num2 = DateHour % 10;
        setServo(1,num1);
        setServo(2,num2);
        SerialPrint();
      }
    
      if(!(DateMinute == NTP.getMinutes())){
        DateMinute = NTP.getMinutes();
        num3 = DateMinute / 10;
        num4 = DateMinute % 10;
        setServo(3,num3);
        setServo(4,num4);
        SerialPrint();
      }
    
      if(!(DateSecond == NTP.getSeconds())){
        DateSecond = NTP.getSeconds();
        num5 = DateSecond / 10;
        num6 = DateSecond % 10;
        setServo(5,num5);
        setServo(6,num6);
        SerialPrint();
      }
    }
    

    总结

    通过更新库和修改代码中使用的函数名,您应该能够解决报错问题。如果问题依然存在,请确保查阅最新的 NTPClientLib 库文档,以获取正确的函数名和用法。希望这些步骤能帮助您顺利解决问题。

    如果该回答解决了您的问题,请采纳!如果没有,请私信联系或评论您的疑惑

    评论

报告相同问题?

问题事件

  • 创建了问题 8月16日

悬赏问题

  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振