La ventilation varie en fonction de l’état de la machine laser. Mais il est aussi possible de la bloque manuellement a une valeur de son choix.
- En temps normal : 10% de ventilation
- En fonctionnellement 50% de ventilation puis minimum 120 sec de compte à rebours
- En mode coupe 100% de ventilation puis minimum 30 sec de compte à rebours
const int pinWind = 3;
const int pinRun = 4;
const int pinBlower = 6;
const int pinUp = 7;
const int pinDown = 8;
int outputValue;
bool inWind = 0;
bool inRun = 0;
/// Setup ///
int timeWind = 30; // sec
int timeRun = 120; // sec
int powerWind = 100; // sec
int powerRun = 50; // %
int powerDefault = 10; // %
int powerBlower = 100; // %
int addTimeMin = 30; // sec
int addTimeMax = 120; //sec
String v = "V 3.7";
////////////@
int cdWind = 0;
int cdRun = 0;
int powerManual = -1;
int cuRun = 0;
int addTime = 0;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
byte customChar[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
byte customCharI[] = {0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00};
byte customCharII[] = {0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00};
byte customCharIII[] = {0x00, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00};
byte customCharIIII[] = {0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00};
byte customCharIIIII[] = {0x00, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00};
void setup() {
pinMode(pinWind, INPUT_PULLUP);
pinMode(pinRun, INPUT_PULLUP);
pinMode(pinUp, INPUT_PULLUP);
pinMode(pinDown, INPUT_PULLUP);
pinMode(pinBlower, OUTPUT);
lcd.init(); // initialize the lcd
lcd.init(); // Print a message to the LCD.
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("KBC Blower crt");
lcd.setCursor(4, 1);
lcd.print(v);
lcd.createChar(0, customChar);
lcd.createChar(1, customCharI);
lcd.createChar(2, customCharII);
lcd.createChar(3, customCharIII);
lcd.createChar(4, customCharIIII);
lcd.createChar(5, customCharIIIII);
delay(2000);
lcd.clear();
}//setup
void loop() {
// Check input //
inWind = !digitalRead(pinWind);
inRun = !digitalRead(pinRun);
if (!digitalRead(pinUp) && powerManual < 100 ) {
powerManual++;
delay(100);
}
if (!digitalRead(pinDown) && powerManual > -1) {
powerManual--;
delay(100);
}
if (!digitalRead(pinDown) && powerManual == -1) {
if (cdRun == 0 && cdWind == 0) {
cdRun = (timeRun * 100);
cdWind = (timeWind * 100);
}
else {
cdRun = 0;
cdWind = 0;
}
delay(100);
}
// Countdown //
if (inWind) cdWind = (timeWind * 100) + addTime;
if (inRun) {
cdRun = (timeRun * 100) + (addTime * 2);
if (cuRun > (addTimeMax * 3))cuRun++;
}
else if (cuRun > 0) cuRun--;
addTime = map(cuRun, addTimeMin * 100, addTimeMax * 100, 0, 200);
if (cdWind > 0) cdWind-- ;
if (cdRun > 0) cdRun-- ;
// Adjuste output percent //
if ( powerManual >= 0) {
powerBlower = powerManual;
}
else if (cdWind > 0) {
powerBlower = powerWind;
}
else if (cdRun > 0) {
powerBlower = powerRun;
}
else {
powerBlower = powerDefault;
}
// Display //
lcd.setCursor(0, 0);
lcd.print(String("Fan ") + String(powerBlower) + String("% "));
lcd.setCursor(10, 0);
lcd.print(String("["));
if (powerBlower >= 20) {
lcd.printByte(5);
}
else if (powerBlower >= 10) {
lcd.printByte(4);
}
else {
lcd.printByte(0);
}
if (powerBlower >= 50) {
lcd.printByte(3);
}
else if (powerBlower >= 40) {
lcd.printByte(2);
}
else if (powerBlower >= 30) {
lcd.printByte(1);
}
else {
lcd.printByte(0);
}
if (powerBlower >= 80) {
lcd.printByte(3);
}
else if (powerBlower >= 70) {
lcd.printByte(2);
}
else if (powerBlower >= 60) {
lcd.printByte(1);
}
else {
lcd.printByte(0);
}
if (powerBlower >= 100) {
lcd.printByte(2);
}
else if (powerBlower >= 90) {
lcd.printByte(1);
}
else {
lcd.printByte(0);
}
lcd.print(String("]"));
if ( powerManual >= 0) {
lcd.setCursor(0, 1);
lcd.print(String("Manual Mode "));
}
else {
lcd.setCursor(0, 1);
if (inWind) lcd.print(String("W*") + String(cdWind / 100) + String(" "));
else if (cdWind == 0) lcd.print(String("W OFF "));
else lcd.print(String("W ") + String(cdWind / 100) + String(" "));
lcd.setCursor(8, 1);
if (inRun) lcd.print(String("R*") + String(cdRun / 100) + String(" "));
else if (cdRun == 0) lcd.print(String("R OFF "));
else lcd.print(String("R ") + String(cdRun / 100) + String(" "));
}
outputValue = map(powerBlower, 0, 100, 0, 255);
analogWrite(pinBlower, outputValue);
delay(10);
}//loop


