arduino 简易智能花盆

编辑器:arduino IDE

主板:arduino uno

传感器:

0.96寸的OLED屏(四脚)
声音模块
土壤温湿度模块
DS18B20温度模块(这里用到防水的)
光敏电阻模块(买成三脚的了只能显示高低,可换四脚显示数字) 
arduino扩展板 (看个人需求)
杜邦线(母对母,公对母)
 

功能:能在OLED屏上显示出传感器的数据,并模拟显示出植物对应的状态的图案
可自己设置零界点

(买的少的话pdd即可,百元以内轻轻松松,还可以买个wifi模块,做个app上位机)

代码如下:

 

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>


#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int temperatureSensorPin = A0;  // 温度
const int lightSensorDOPin = 7;  // 光敏
const int soilMoistureSensorPin = A2; // 湿度
const int soundSensorPin = A3;  // 声音
OneWire oneWire(A0); // 使用一线式总线连接DS18B20传感器
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextColor(WHITE);
  display.clearDisplay();
  display.display();
  delay(2000);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  sensors.begin(); // 初始化DS18B20传感器
  pinMode(soundSensorPin, INPUT); // 初始化声音传感器引脚
  pinMode(lightSensorDOPin, INPUT);  // 设置数字光敏传感器的数字输出引脚为输入
}

static const unsigned char PROGMEM pic[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x40,0x00,
0x00,0x00,0x0F,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0xE0,0x00,
0x00,0x00,0x7C,0x00,0x00,0x00,0xE0,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF0,0x00,
0x00,0x03,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x07,0xF0,0x00,0x00,0x03,0xF8,0x00,
0x00,0x0F,0xE0,0x00,0x00,0x07,0xF8,0x00,0x00,0x1F,0xE0,0x00,0x00,0xFF,0xFF,0xE0,
0x00,0x3F,0xC0,0x00,0x03,0xFF,0xFF,0xF8,0x00,0x7F,0xC0,0x00,0x01,0xFF,0xFF,0xF0,
0x00,0xFF,0x80,0x00,0x00,0xFF,0xFF,0xE0,0x01,0xFF,0x80,0x00,0x00,0x7F,0xFF,0xC0,
0x01,0xFF,0x80,0x00,0x00,0x3F,0xFF,0x80,0x03,0xFF,0x80,0x00,0x00,0x1F,0xFF,0x00,
0x03,0xFF,0x80,0x00,0x00,0x1F,0xFF,0x00,0x07,0xFF,0x00,0x00,0x00,0x1F,0xFF,0x00,
0x07,0xFF,0x00,0x00,0x00,0x1F,0xFF,0x00,0x0F,0xFF,0x00,0x00,0x00,0x1F,0xFF,0x00,
0x0F,0xFF,0x00,0x00,0x00,0x1F,0xFF,0x00,0x0F,0xFF,0x00,0x00,0x00,0x3F,0x3F,0x00,
0x1F,0xFF,0x00,0x00,0x00,0x3E,0x0F,0x80,0x1F,0xFF,0x80,0x00,0x00,0x38,0x03,0x80,
0x1F,0xFF,0x80,0x00,0x00,0x20,0x00,0x00,0x1F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,
0x0F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x08,0x0F,0xFF,0xFF,0x80,0x00,0x00,0x00,0x18,
0x07,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x30,0x07,0xFF,0xFF,0xF0,0x00,0x00,0x00,0xF0,
0x03,0xFF,0xFF,0xF8,0x00,0x00,0x01,0xE0,0x03,0xFF,0xFF,0xFE,0x00,0x00,0x07,0xE0,
0x03,0xFF,0xFF,0xFF,0x80,0x00,0x3F,0xC0,0x01,0xFF,0xFF,0xFF,0xF8,0x01,0xFF,0xC0,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,
0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,
0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF0,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

static const unsigned char PROGMEM pic1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0xC0,0x00,0x00,0x00,
0x00,0x00,0x03,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x07,0xC1,0x80,0x00,0x00,0x00,
0x00,0x00,0x07,0xC3,0x80,0x00,0x00,0x00,0x00,0x00,0x0F,0xC3,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1F,0xC3,0xC0,0x00,0x00,0x00,0x00,0x00,0x1F,0xE3,0xE0,0x00,0x02,0x00,
0x00,0x00,0x1F,0xF1,0xF0,0x00,0x0E,0x00,0x00,0x00,0x1F,0xF8,0xFC,0x00,0x1C,0x00,
0x00,0x00,0x1F,0xF8,0xFE,0x00,0x3C,0x00,0x00,0x00,0x1F,0xFC,0x7F,0x80,0x78,0x00,
0x00,0x00,0x0F,0xFE,0x3F,0xC0,0x78,0x00,0x00,0x00,0x07,0xFE,0x3F,0xF0,0x78,0x00,
0x00,0x00,0x07,0xFE,0x1F,0xF8,0x78,0x00,0x00,0x00,0x03,0xFE,0x1F,0xFC,0x3C,0x00,
0x00,0x00,0x01,0xFE,0x1F,0xFE,0x3C,0x00,0x00,0x00,0x00,0xFE,0x1F,0xFE,0x3C,0x00,
0x00,0x00,0xC0,0x7C,0x1F,0xFE,0x3E,0x00,0x00,0x00,0x40,0x78,0x3F,0xFE,0x3E,0x00,
0x00,0x00,0x60,0x78,0x7F,0xFE,0x3C,0x00,0x00,0x00,0x60,0x70,0xFF,0xFE,0x38,0x00,
0x00,0x00,0x70,0xE3,0xFF,0xFE,0x70,0x00,0x00,0x00,0x70,0xC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0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};


static const unsigned char PROGMEM pic2[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x07,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x00,
0x00,0x00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F0,0x00,0xFF,0xFF,0xF8,0x00,
0x00,0x0F,0xF0,0x00,0xFF,0xFF,0xF0,0x00,0x00,0x0F,0xF8,0x00,0xFF,0xFF,0xF0,0x00,
0x00,0x07,0xFC,0x00,0xFF,0xFF,0xE0,0x00,0x00,0x07,0xFF,0x00,0xFF,0xFF,0xE0,0x00,
0x00,0x03,0xFF,0x80,0xFF,0xFF,0xC0,0x00,0x00,0x01,0xFF,0xE0,0xFF,0xFF,0x80,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x00,0x00,
0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x00,
0x00,0x00,0x07,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xC0,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};



static const unsigned char PROGMEM pic3[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,
0x00,0x00,0x00,0x00,0x0F,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x07,0x80,
0x00,0x00,0x00,0x18,0x0F,0xF0,0x07,0xC0,0x00,0x00,0x00,0x3C,0x01,0xF8,0x03,0xC0,
0x00,0x00,0x00,0x7E,0x00,0x7E,0x01,0xE0,0x00,0x00,0x00,0x7F,0x00,0x3E,0x01,0xE0,
0x00,0x00,0x00,0xFF,0x80,0x1F,0x00,0xF0,0x00,0x00,0x00,0xFF,0xC0,0x0F,0x80,0xF0,
0x00,0x00,0x01,0xFF,0xE0,0x07,0xC0,0x78,0x00,0x00,0x01,0xFF,0xF0,0x03,0xC0,0x78,
0x00,0x00,0x03,0xFF,0xF8,0x01,0xE0,0x38,0x00,0x00,0x03,0xFF,0xFC,0x01,0xE0,0x38,
0x00,0x00,0x07,0xFF,0xFE,0x00,0xF0,0x3C,0x00,0x00,0x07,0xFF,0xFF,0x00,0xF0,0x3C,
0x00,0x00,0x0F,0xFF,0xFF,0x80,0x70,0x18,0x00,0x00,0x0F,0xFF,0xFF,0xC0,0x60,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xF0,0x00,0x00,
0x00,0x00,0x3F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,
0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,
0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x07,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xF0,0x00,0x00,
0x00,0x0F,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x1F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xF0,0x00,0x00,0x00,
0x00,0x3F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
0x07,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x1F,0x1F,0xFF,0x00,0x00,0x00,0x00,0x00,0x1E,0x0F,0xFF,0x80,0x00,0x00,0x00,0x00,
0x1E,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x0F,0x07,0x9F,0xE0,0x00,0x00,0x00,0x00,
0x07,0x8F,0x0F,0xF0,0x00,0x00,0x00,0x00,0x03,0xCF,0x07,0xF8,0x00,0x00,0x00,0x00,
0x01,0xFE,0x03,0xFC,0x00,0x00,0x00,0x00,0x00,0xFC,0x01,0xFC,0x00,0x00,0x00,0x00,
0x00,0x78,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};


static const unsigned char PROGMEM pic4[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xE0,0x00,0x00,0x00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x00,
0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};



void loop() {
  delay(2000);

  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0); // 获取DS18B20传感器的温度值
  int lightIntensity = digitalRead(lightSensorDOPin); // 使用digitalRead读取数字光敏传感器的状态
  int soilMoisture = analogRead(soilMoistureSensorPin);
  int soundLevel = analogRead(soundSensorPin);

  // // 在OLED上显示传感器数据
  display.clearDisplay();
  display.setCursor(68, 0);
  display.print("T: ");
  display.print(temperatureC);
  display.print(" C");
  display.setCursor(68, 10);
  display.print("L: ");
  display.print(lightIntensity == LOW ? "High" : "Low"); // 显示光强状态
  display.setCursor(68, 20);
  display.print("D: ");
  display.print(soilMoisture);
  display.print(" %");
  display.setCursor(68, 30);
  display.print("S: ");
  display.print(soundLevel);
  display.print(" dB");
  display.display();


  // 根据传感器数据选择表情
  if (lightIntensity == HIGH) {
    // 低光照强度
    // display.setCursor(35, 40);
    // display.clearDisplay();//清屏
    display.drawBitmap(0, 0, pic, 64, 64, 1); //画出字符对应点阵数据
    display.setCursor(68, 40);
    display.print("Sad :(");
    display.display();//开显示    
    delay(2000);
  } else if (temperatureC > 25) {
    // 高温
    // display.setCursor(35, 40);
    // display.clearDisplay();//清屏
    display.drawBitmap(0, 0, pic1, 64, 64, 1); //画出字符对应点阵数据
    display.setCursor(68, 40);
    display.print("Hot :S");
    display.display();//开显示  
    delay(2000);
  } else if (soilMoisture > 500) {
    // 土壤过干
    // display.setCursor(35, 40);
    // display.clearDisplay();//清屏
    display.drawBitmap(0, 0, pic2, 64, 64, 1); //画出字符对应点阵数据
    display.setCursor(68, 40);
    display.print("dry :S");
    display.display();//开显示
    
    delay(2000);
  } else if (soundLevel > 30) {
    // 声音强
    // display.setCursor(35, 40);
    // display.clearDisplay();//清屏
    display.drawBitmap(0, 0, pic3, 64, 64, 1); //画出字符对应点阵数据
    display.setCursor(68, 40);
    display.print("Loud :O");
    display.display();//开显示
    delay(2000);
  } else {
    // 默认表情
    // display.setCursor(35, 40);
    // display.clearDisplay();//清屏
    display.drawBitmap(0, 0, pic4, 64, 64, 1); //画出字符对应点阵数据
    display.setCursor(68, 40);
    display.print("Smile :)");
    display.display();//开显示
    delay(2000);
  }
  display.display();
}

 效果如下图:


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/132974.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

软件测试的终点是“测试开发”吗?

前言 在一线大厂&#xff0c;没有测试这个岗位&#xff0c;只有测开这个岗位&#xff0c;即使是做业务测试&#xff0c;那么你的title也是测开。 所以想聊一聊测开的看法&#xff0c;但不代表这是正确的看法&#xff0c;仅供参考。 没来阿里之前我对测开的看法 一直以为专职做自…

软件测试金融项目,在测试的时候一定要避开的一些雷区

软件测试金融项目需要格外谨慎和专注&#xff0c;因为这些项目通常涉及大量的交易、用户隐私和其他敏感信息。以下是一些软件测试金融项目时需要关注的方面&#xff1a; 1. 数据保护 在测试金融项目时&#xff0c;必须确保用户数据和投资信息得到保护。测试人员必须确保测试环…

我干了8年测试,告诉你现在软件测试还能不能找到工作!

观点&#xff1a;如果你还是以前的思维来学习测试&#xff0c;那你肯定是找不到工作&#xff01; 我做测试工作有将近8年的时间&#xff0c;蚂蚁金服做过2年&#xff0c;因为加班太多离职了。目前在一家国企上市公司&#xff0c;一年能拿三四十个左右&#xff0c;对比头部互联…

信息系统“好用”的标准探讨

数字化转型建设的关键不在建设信息系统。这是为了避免走信息化建设的老路——业务和信息化两张皮&#xff0c;寄希望信息系统解决业务问题。在数字化转型建设中&#xff0c;信息系统仍然是重要抓手和显性成果&#xff0c;是企业业务和数据的承载平台&#xff0c;也是IT厂商向客…

李峋同款的C语言动态爱心代码来了,彩色闪动,附源码

1.前言 最近一部电视剧《点燃我&#xff0c;温暖你》可火啦&#xff0c;大家纷纷在搞男主阿瑟的同款爱心代码&#xff0c;但是虽然网上有它的源码&#xff0c;但都不是 C 语言的&#xff0c;看不懂。我看了一下这个视频&#xff0c;大致分析了一下它的运行过程。用语言描述一下…

【C++】C++11常用特性梳理

C11特性梳理 1. 列表初始化2. auto & decltype3. 右值引用3.1. 左右值引用比较3.2. 右值引用的意义3.3. 万能引用与完美转发3.4. 移动构造与移动赋值 4. default & delete5. 可变参数模板6. push_back 与 emplace_back7. lambda表达式7.1. 捕捉列表 8. function包装器8…

(一)QML加载离线地图+标记坐标点

1、实现效果 加载离线地图瓦片、鼠标拖拽、滚轮缩放在地图上固定坐标位置标注地名 &#xff08;一&#xff09;QML加载离线地图标记坐标点&#xff1a;MiniMap-mini 2、实现方法 2.1、使用工具下载离线地图 不废话&#xff0c;直接搬别人的砖&#xff0c;曰&#xff1a;他山…

VirtualBox网络地址转换(NAT),宿主机无法访问虚拟机的问题

问题&#xff1a;NAT模式下&#xff0c;默认只能从内访问外面&#xff0c;而不能从外部访问里面&#xff0c;所以只能单向ping通&#xff0c;虚拟机的ip只是内部ip。 PS&#xff1a;桥接则是与主机公用网卡&#xff0c;有独立的外部ip。 解决&#xff1a;NAT模式可以通过配置 …

好物周刊#30:Github 上大学

https://github.com/cunyu1943/JavaPark https://yuque.com/cunyu1943 村雨遥的好物周刊&#xff0c;记录每周看到的有价值的信息&#xff0c;主要针对计算机领域&#xff0c;每周五发布。 一、项目 1. Fighting Design 一款灵活、优质的组件库&#xff0c;可在 vue3 应用程…

【api_fox】ApiFox简单操作

1、get和post请求的区别&#xff1f;2、接口定义时的传参格式&#xff1f;3、保存接口文档 apifox当中接口文档的设计和接口用例的执行是分开的。 1、get和post请求的区别&#xff1f; 2、接口定义时的传参格式&#xff1f; 3、保存接口文档 就生成如下的接口文档。

C语言实现编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n

完整代码&#xff1a; /*编写一个函数&#xff0c;输入n为偶数时&#xff0c;调用函数求1/21/4...1/n,当输入n为奇数时&#xff0c; 调用函数1/11/3...1/n */ #include<stdio.h>//n为偶数 double Odd(int n){double sum0;//i为2&#xff0c;4&#xff0c;6....for (int …

linux_day02

1、链接&#xff1a;LN 一个点表示当前工作目录&#xff0c;两个点表示上一层工作目录&#xff1b; 目录的本质&#xff1a;文件&#xff08;该文件储存目录项&#xff0c;以链表的形式链接&#xff0c;每个结点都是目录项&#xff0c;创建文件相当于把目录项添加到链表中&…

在Spring Boot中使用JTA实现对多数据源的事务管理

了解事务的都知道&#xff0c;在我们日常开发中单单靠事务管理就可以解决绝大多数问题了&#xff0c;但是为啥还要提出JTA这个玩意呢&#xff0c;到底JTA是什么呢&#xff1f;他又是具体来解决啥问题的呢&#xff1f; JTA JTA&#xff08;Java Transaction API&#xff09;是…

C语言--青蛙跳台阶【内容超级详细】

今天与大家分享一下递归的经典题目--青蛙跳台阶问题。 一.引子 电影《少年班》&#x1f357;中的老师在全国各地寻找天才少年时&#xff0c;就问了一个这样的问题&#xff0c;有20阶台阶&#xff0c;每次只能上一阶或两阶&#xff0c;总共有多少种上法&#xff1f;这个少年王…

【LeetCode刷题日志】138.随机链表的复制

&#x1f388;个人主页&#xff1a;库库的里昂 &#x1f390;C/C领域新星创作者 &#x1f389;欢迎 &#x1f44d;点赞✍评论⭐收藏✨收录专栏&#xff1a;LeetCode 刷题日志&#x1f91d;希望作者的文章能对你有所帮助&#xff0c;有不足的地方请在评论区留言指正&#xff0c;…

WebSphere Liberty 8.5.5.9 (一)

WebSphere Liberty 8.5.5.9 (一) 安装 1. 从官网下载 WebSphere Liberty 8.5.5.9 2. 解压 解压到 D:\wlp-webProfile7-java8-8.5.5.93. 启动 D:\wlp-webProfile7-java8-8.5.5.9\wlp\bin>server start 正在启动服务器 defaultServer。 服务器 defaultServer 已启动。4. …

让你的win10/win11系统变得不再卡顿,优雅草伊凡整理-长期更新-如何让windows操作系统不用老是重装在不断的更新中依然保持流畅运行

概述 如题&#xff1a;让你的win10/win11系统变得不再卡顿&#xff0c;优雅草伊凡整理-长期更新-如何让windows操作系统不用老是重装在不断的更新中依然保持流畅运行 本文长期更新&#xff0c;本次更新2023年11月8日&#xff01; 很多时候 我们的win10win11系统不管再怎么关…

【Python】20大报告生成词云

这个我其实写过一篇类似的博客&#xff0c;但是那个的文件对象是.csv&#xff0c;对应到.docx文件的话&#xff0c;就不太适用了。如下&#xff1a; Python生成词云-CSDN博客 代码&#xff1a; import jieba import os import wordcloud import numpy as np from PIL import…

自动化测试框架Playwright安装以及使用

最近&#xff0c;微软开源了一个非常强大的自动化项目叫 playwright-python 它支持主流的浏览器&#xff0c;包含&#xff1a;Chrome、Firefox、Safari、Microsoft Edge 等&#xff0c;同时支持以无头模式、有头模式运行&#xff0c;并提供了同步、异步的 API&#xff0c;可以…

【读点论文】结构化剪枝

结构化剪枝 在一个神经网络模型中&#xff0c;通常包含卷积层、汇合层、全连接层、非线形层等基本结构&#xff0c;通过这些基本结构的堆叠&#xff0c;最终形成我们所常用的深度神经网络。 早在 1998 年&#xff0c;LeCun 等人使用少数几个基本结构组成 5 层的 LeNet-5 网络&…