Arduino應用
老化箱校正
<C>
- include <SPI.h>
- include <SD.h>
- include "Max6675.h"
File myFile; // Max6675 module: SO on pin #8, SS on pin #9, CSK on pin #10 of Arduino UNO // Other pins are capable to run this library, as long as digitalRead works on SO, // and digitalWrite works on SS and CSK Max6675 ts(5, 6, 7);
void setup() {
Serial.begin(9600);
while (!Serial) { // 等待串列埠連線
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("Fail!");
return;
}
Serial.println("Success!");
ts.setOffset(0);
}
void loop() {
float t= ts.getCelsius();
String strT= String("")+t+","+millis();
Serial.println(strT);
myFile = SD.open("card.txt", FILE_WRITE);
myFile.println(strT);
myFile.close(); // 關閉檔案
Serial.println("Completed!");
delay(10000);
} </c>
- 增加看板
<c>
- include <SPI.h>
- include <RGBmatrixPanel.h>
- include "Max6675.h"
- define CLK 8 // USE THIS ON ARDUINO UNO, ADAFRUIT METRO M0, etc.
//#define CLK A4 // USE THIS ON METRO M4 (not M0) //#define CLK 11 // USE THIS ON ARDUINO MEGA
- define OE 9
- define LAT 10
- define A A0
- define B A1
- define C A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); Max6675 ts(A3,A4,A5);
void setup() {
Serial.begin(9600); matrix.begin(); ts.setOffset(0);
matrix.fillScreen(matrix.Color333(0, 0, 0)); matrix.setCursor(1, 0); // start at top left, with one pixel of spacing matrix.setTextSize(1); // size 1 == 8 pixels high matrix.setTextColor(matrix.Color333(7,0,0));// print each letter with a rainbow color
}
void loop() {
float t= ts.getCelsius();
String strT= String("")+t+","+millis();
Serial.println(strT);
matrix.fillScreen(matrix.Color333(0, 0, 0));
matrix.setCursor(0, 0);
matrix.setTextColor(matrix.Color333(7,0,0));
matrix.print(t);
matrix.setCursor(0, 8);
matrix.setTextColor(matrix.Color333(0,7,0));
matrix.print(millis()/1000);
// 關閉檔案
Serial.println("Completed!");
delay(3000);
} </c>