2023年8月1日 星期二

Arduino uno 搭0.96寸 OLED模組,讓ChatGPT幫我們寫程式

 

接線方式:(參考:https://blog.jmaker.com.tw/arduino-ssd1306-oled/)



第一個程式,寫一個計時功能。(因為Arduino UNO沒有時鐘,所以改計時)

================================

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels

#define SCREEN_HEIGHT 64 // OLED display height, in pixels


// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);


void setup() {

  // initialize and clear display

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Address 0x3C for 128x64

  display.clearDisplay();

  display.display();

}


void loop() {

  display.clearDisplay();

  display.setTextSize(2);

  display.setTextColor(WHITE);


  unsigned long currentTime = millis();

  unsigned long seconds = currentTime / 1000;

  unsigned long minutes = seconds / 60;

  unsigned long hours = minutes / 60;


  seconds = seconds % 60;

  minutes = minutes % 60;

  

  display.setCursor(0,0);

  if (hours < 10)

    display.print('0');

  display.print(hours, DEC);


  display.print(':');

  

  if (minutes < 10)

    display.print('0');

  display.print(minutes, DEC);


  display.print(':');

  

  if (seconds < 10)

    display.print('0');

  display.print(seconds, DEC);


  display.display();

  delay(1000);

}

==========================
實測可行。



第二個程式:把原本數字計時,改成指計。
===========================

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define CLOCK_CENTER_X 64
#define CLOCK_CENTER_Y 32
#define CLOCK_RADIUS 30

void setup() {
  // initialize and clear display
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Address 0x3C for 128x64
  display.clearDisplay();
  display.display();
}

void loop() {
  display.clearDisplay();

  unsigned long currentTime = millis();
  unsigned long seconds = currentTime / 1000;
  unsigned long minutes = seconds / 60;
  unsigned long hours = minutes / 60;

  seconds = seconds % 60;
  minutes = minutes % 60;
  hours = hours % 12;

  // draw clock face
  display.drawCircle(CLOCK_CENTER_X, CLOCK_CENTER_Y, CLOCK_RADIUS, WHITE);
  
  // draw hour hand
  drawHand(hours / 12.0, CLOCK_RADIUS * 0.5, 4);
  
  // draw minute hand
  drawHand(minutes / 60.0, CLOCK_RADIUS * 0.7, 2);

  // draw second hand
  drawHand(seconds / 60.0, CLOCK_RADIUS * 0.9, 1);
  
  display.display();
  delay(1000);
}

void drawHand(float fraction, float handLength, uint8_t handWidth) {
  float angle = fraction * 2.0 * PI - PI / 2;
  int16_t x = (int16_t)(CLOCK_CENTER_X + cos(angle) * handLength);
  int16_t y = (int16_t)(CLOCK_CENTER_Y + sin(angle) * handLength);
  display.drawLine(CLOCK_CENTER_X, CLOCK_CENTER_Y, x, y, WHITE);
  display.drawLine(CLOCK_CENTER_X + 1, CLOCK_CENTER_Y, x + 1, y, WHITE);
  display.drawLine(CLOCK_CENTER_X, CLOCK_CENTER_Y + 1, x, y + 1, WHITE);
  display.drawLine(CLOCK_CENTER_X + 1, CLOCK_CENTER_Y + 1, x + 1, y + 1, WHITE);
}
========================
測試成功:





第三個程式:左邊指令,右邊數字時鐘

=第一次===

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define CLOCK_CENTER_X 32
#define CLOCK_CENTER_Y 32
#define CLOCK_RADIUS 30

void setup() {
  // initialize and clear display
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Address 0x3C for 128x64
  display.clearDisplay();
  display.display();
}

void loop() {
  display.clearDisplay();

  unsigned long currentTime = millis();
  unsigned long seconds = currentTime / 1000;
  unsigned long minutes = seconds / 60;
  unsigned long hours = minutes / 60;

  seconds = seconds % 60;
  minutes = minutes % 60;
  hours = hours % 24;

  // draw clock face
  display.drawCircle(CLOCK_CENTER_X, CLOCK_CENTER_Y, CLOCK_RADIUS, WHITE);
 
  // draw hour hand
  drawHand(hours / 12.0, CLOCK_RADIUS * 0.5, 4);
 
  // draw minute hand
  drawHand(minutes / 60.0, CLOCK_RADIUS * 0.7, 2);

  // draw second hand
  drawHand(seconds / 60.0, CLOCK_RADIUS * 0.9, 1);

  // draw digital clock
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(70,0);
  if (hours < 10)
    display.print('0');
  display.print(hours, DEC);

  display.print(':');
 
  if (minutes < 10)
    display.print('0');
  display.print(minutes, DEC);

  display.print(':');
 
  if (seconds < 10)
    display.print('0');
  display.print(seconds, DEC);
 
  display.display();
  delay(1000);
}

void drawHand(float fraction, float handLength, uint8_t handWidth) {
  float angle = fraction * 2.0 * PI - PI / 2;
  int16_t x = (int16_t)(CLOCK_CENTER_X + cos(angle) * handLength);
  int16_t y = (int16_t)(CLOCK_CENTER_Y + sin(angle) * handLength);
  display.drawLine(CLOCK_CENTER_X, CLOCK_CENTER_Y, x, y, WHITE);
  display.drawLine(CLOCK_CENTER_X + 1, CLOCK_CENTER_Y, x + 1, y, WHITE);
  display.drawLine(CLOCK_CENTER_X, CLOCK_CENTER_Y + 1, x, y + 1, WHITE);
  display.drawLine(CLOCK_CENTER_X + 1, CLOCK_CENTER_Y + 1, x + 1, y + 1, WHITE);
}

數字超過寬度,跑到下一行。


請chatgpt修改:寬度

=====第二次============

#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); #define CLOCK_CENTER_X 32 #define CLOCK_CENTER_Y 32 #define CLOCK_RADIUS 30 void setup() { // initialize and clear display display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x64 display.clearDisplay(); display.display(); } void loop() { display.clearDisplay(); unsigned long currentTime = millis(); unsigned long seconds = currentTime / 1000; unsigned long minutes = seconds / 60; unsigned long hours = minutes / 60; seconds = seconds % 60; minutes = minutes % 60; hours = hours % 24; // draw clock face display.drawCircle(CLOCK_CENTER_X, CLOCK_CENTER_Y, CLOCK_RADIUS, WHITE); // draw hour hand drawHand(hours / 12.0, CLOCK_RADIUS * 0.5, 4); // draw minute hand drawHand(minutes / 60.0, CLOCK_RADIUS * 0.7, 2); // draw second hand drawHand(seconds / 60.0, CLOCK_RADIUS * 0.9, 1); // draw digital clock display.setTextSize(1); // reduce text size display.setTextColor(WHITE); display.setCursor(72,0); // adjust cursor position if (hours < 10) display.print('0'); display.print(hours, DEC); display.print(':'); if (minutes < 10) display.print('0'); display.print(minutes, DEC); display.print(':'); if (seconds < 10) display.print('0'); display.print(seconds, DEC); display.display(); delay(1000); } void drawHand(float fraction, float handLength, uint8_t handWidth) { float angle = fraction * 2.0 * PI - PI / 2; int16_t x = (int16_t)(CLOCK_CENTER_X + cos(angle) * handLength); int16_t y = (int16_t)(CLOCK_CENTER_Y + sin(angle) * handLength); display.drawLine(CLOCK_CENTER_X, CLOCK_CENTER_Y, x, y, WHITE); display.drawLine(CLOCK_CENTER_X + 1, CLOCK_CENTER_Y, x + 1, y, WHITE); display.drawLine(CLOCK_CENTER_X, CLOCK_CENTER_Y + 1, x, y + 1, WHITE); display.drawLine(CLOCK_CENTER_X + 1, CLOCK_CENTER_Y + 1, x + 1, y + 1, WHITE); }

是ok的。

拍照有斷線,實際是沒有的

2023年6月21日 星期三

台達橡膠雙缸熱壓機解決方案實時監控成型加熱溫度,優化鞋底製程、提高產能



鞋子不只是保護我們的腳,也成為了我們生活中的風格聲明。
由鞋面、鞋身、中底到大底,每一個部分都是由精細工藝製成,其中,大底的製程尤其關鍵。
在此過程中,雙缸熱壓機經由壓力和熱度塑造出韌性十足且具有高強度的大底。
然而,由於鞋款更新速度快,製鞋業者須在保持產品品質的同時,提升生產效率。
如何解決這個挑戰?

台達團隊的橡膠雙缸熱壓機解決方案或許是答案。







台達團隊整合自家產品,開發出一種新的橡膠雙缸熱壓機解決方案。

採用油電伺服節能系統取代傳統的油壓系統,這種解決方案能提高成型品質,
並加速生產速度,更重要的是,它還能達到節能的目標。


這個解決方案的核心是台達的高功能泛用型控制器,它具有強大的定位控制功能,
可以透過CANopen網路或脈波控制來支援多軸數。
這樣的設計使得鞋底產線能夠靈活地擴充設備站別。
此外,這個方案還採用了台達的多迴路模組化溫度控制器,
能夠獲得溫度變化的訊號,然後透過Modbus通訊將資料傳輸至人機介面。
使用者能透過直覺友善的操作介面,輕鬆快速地控制整個生產過程和設定。

導入台達的橡膠雙缸熱壓機解決方案,業者能彈性地增減熱壓機站別數量,
並將各站的溫度進行集中管理,快速排除任何溫度異常,確保產品品質穩定,
進一步提升產品的競爭力。最重要的是,
這個方案的核心—台達的高功能泛用型控制器,能確保製程順序的準確無誤,
提供全面的解決方案,助力業者轉型為智能製造,迎向新紀元。

鞋子不只是保護我們的腳,也能反映出社會的發展和人類的創新精神。
台達團隊的橡膠雙缸熱壓機解決方案,正好展現了如何透過創新的技術,
提升產品的品質與效率,同時對環境負責。藉由這樣的創新,
我們有信心在未來的製鞋業中繼續留下深刻的足跡。





2023年6月16日 星期五

【活動宣傳】台達2023「智造」線上論壇 – 部署未來工廠,搶占智造先機