/*建立于2018年9月17日,用于塑封机改造成热转印机
2019年1月9日继续完成
*/
#define ntcpin a0
#define setpin a1
#define heat 2
#define motor 3
#define red 4
#define blue 5
#define use 10
int tsetvalue;
double tnowvalue;
int tset;
double tnow;
bool play;
#include
#include
//latchpin, clockpin, datapin,
shiftdisplay display(8, 7, 6, common_cathode, 3);
void setup() {
pinmode(heat, output);
pinmode(motor, output);
pinmode(red, output);
pinmode(blue, output);
}
///
void loop() {
if (play) {
tsetvalue = analogread(setpin);
tset = 0.127077 * tsetvalue 50;
digitalwrite(blue, low);
digitalwrite(red, high);
put(tnow, tset, tset);
play = false;
}
else {
tnowvalue = analogread(ntcpin);
tnow = 200 * (1024 - tnowvalue) / tnowvalue;
tnow = log(tnow) / 3950;
tnow = (1 / 293.15) - tnow ;
tnow = (1 / tnow) - 273.15;
digitalwrite(red, low);
digitalwrite(blue, high);
put(tnow, tset, tnow);
play = true;
}
}
void put(int nowt, double sett , int play1) {
if (nowt > sett) {
display.set(play1);
digitalwrite(heat, low);
digitalwrite(use, high);
digitalwrite(motor, high);
display.show(400);
digitalwrite(motor, low);
display.show(100);
}
else {
display.set(play1);
digitalwrite(heat, high);
digitalwrite(use, low);
digitalwrite(motor, high);
display.show(500);
}
}
还没有评论,来说两句吧...