这个代码不知道怎么写了麻烦大家帮帮忙
#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("Hi CAH!");
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.getTimeMinutes())){
DateMinute = NTP.getTimeMinutes();
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:32: error: reference to 'byte' is ambiguous
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/LwipDhcpServer.h:36,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiAP.h:30,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:35,
from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:3:
c:\users\�����������\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstddef:69:14: note: candidates are: 'enum class std::byte'
69 | enum class byte : unsigned char {};
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Temp\arduino\sketches\9FA38AE551DCD66AAF1912B9294CDB2E\sketch\ServoDigitalClock.ino.cpp:1:
C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:161:17: note: 'typedef uint8_t byte'
161 | typedef uint8_t byte;
| ^~~~
In file included from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:5:
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:32: error: 'byte' has not been declared
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:44: error: reference to 'byte' is ambiguous
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/LwipDhcpServer.h:36,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiAP.h:30,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:35,
from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:3:
c:\users\�����������\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstddef:69:14: note: candidates are: 'enum class std::byte'
69 | enum class byte : unsigned char {};
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Temp\arduino\sketches\9FA38AE551DCD66AAF1912B9294CDB2E\sketch\ServoDigitalClock.ino.cpp:1:
C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:161:17: note: 'typedef uint8_t byte'
161 | typedef uint8_t byte;
| ^~~~
In file included from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:5:
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:44: error: 'byte' has not been declared
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:54: error: reference to 'byte' is ambiguous
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/LwipDhcpServer.h:36,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiAP.h:30,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:35,
from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:3:
c:\users\�����������\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstddef:69:14: note: candidates are: 'enum class std::byte'
69 | enum class byte : unsigned char {};
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Temp\arduino\sketches\9FA38AE551DCD66AAF1912B9294CDB2E\sketch\ServoDigitalClock.ino.cpp:1:
C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:161:17: note: 'typedef uint8_t byte'
161 | typedef uint8_t byte;
| ^~~~
In file included from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:5:
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:54: error: 'byte' has not been declared
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:65: error: reference to 'byte' is ambiguous
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/LwipDhcpServer.h:36,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiAP.h:30,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:35,
from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:3:
c:\users\�����������\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstddef:69:14: note: candidates are: 'enum class std::byte'
69 | enum class byte : unsigned char {};
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Temp\arduino\sketches\9FA38AE551DCD66AAF1912B9294CDB2E\sketch\ServoDigitalClock.ino.cpp:1:
C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:161:17: note: 'typedef uint8_t byte'
161 | typedef uint8_t byte;
| ^~~~
In file included from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:5:
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:65: error: 'byte' has not been declared
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
c:\Users\�����������\Documents\Arduino\libraries\NtpClientLib\src/NtpClientLib.h:501:79: error: reference to 'byte' is ambiguous
501 | bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/LwipDhcpServer.h:36,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiAP.h:30,
from c:\Users\�����������\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:35,
from D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:3:
c:\users\�����������\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstddef:69:14: note: candidates are: 'enum class std::byte'
69 | enum class byte : unsigned char {};
| ^~~~
In file included from C:\Users\�����������\AppData\Local\Temp\arduino\sketches\9FA38AE551DCD66AAF1912B9294CDB2E\sketch\ServoDigitalClock.ino.cpp:1:
C:\Users\�����������\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:161:17: note: 'typedef uint8_t byte'
161 | typedef uint8_t byte;
| ^~~~
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:634:18: error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:641:20: error: 'class NTPClient' has no member named 'getTimeMinute'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:648: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:659:24: error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:660:20: error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:668:26: error: 'class NTPClient' has no member named 'getTimeMinutes'; did you mean 'getTimeZoneMinutes'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:669:22: error: 'class NTPClient' has no member named 'getTimeMinutes'; did you mean 'getTimeZoneMinutes'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:677:26: error: 'class NTPClient' has no member named 'getTimeSecond'; did you mean 'getTimeZone'?
D:\桌面\arduino\2.software\ServoDigitalClock\ServoDigitalClock.ino:678:22: error: 'class NTPClient' has no member named 'getTimeSecond'; did you mean 'getTimeZone'?
Multiple libraries were found for "ESP8266WiFi.h"
Used: C:\Users\有梦想的咸鱼\Documents\Arduino\libraries\ESP8266WiFi
Not used: C:\Users\有梦想的咸鱼\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi
exit status 1
Compilation error: 'class NTPClient' has no member named 'getTimeHour24'; did you mean 'getTimeZone'?