หน้าเว็บ

วันอาทิตย์ที่ 17 กันยายน พ.ศ. 2560

Arduino PWM electric brewery boil control// BrewTroller // Control and read out boil speed based on dial // Tyler Tanton // Code free to use, distribute, and edit as needed. Cheers. // January 2012 // Define the LED digit patters, from 0 - 9 // Note that these patterns are for common cathode displays // For common anode displays, change the 1's to 0's and 0's to 1's // 1 = LED on, 0 = LED off, in this order: // Arduino pin: 2,3,4,5,6,7,8 byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 }, // = 0 { 0,1,1,0,0,0,0 }, // = 1 { 1,1,0,1,1,0,1 }, // = 2 { 1,1,1,1,0,0,1 }, // = 3 { 0,1,1,0,0,1,1 }, // = 4 { 1,0,1,1,0,1,1 }, // = 5 { 1,0,1,1,1,1,1 }, // = 6 { 1,1,1,0,0,0,0 }, // = 7 { 1,1,1,1,1,1,1 }, // = 8 { 1,1,1,0,0,1,1 } // = 9 }; // Initialize Variables int potPin = 2; // analog pin location of pot int val = 0; // variable storing value from pot int burner = 0; int cycle = 2; // cycle length of .1 hz int ssrPin= 10; // digital pin location of ssr trigger int ssrAlert=11; void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); writeDot(0); // start with the "dot" off } // Leaving the decimal on the LED digit off void writeDot(byte dot) { digitalWrite(9, dot); } // Writing to the LED Digit Display void sevenSegWrite(byte digit) { byte pin = 2; for (byte segCount = 0; segCount < 7; ++segCount) { digitalWrite(pin, seven_seg_digits[digit][segCount]); ++pin; } } // Reading input from potentiometer void ssr(byte load){ int on = (1.0*load/9)*cycle*1200; int off = (cycle*1200) - on; digitalWrite(ssrPin, LOW); digitalWrite(ssrAlert,LOW); delay(off); digitalWrite(ssrPin, HIGH); digitalWrite(ssrAlert,HIGH); delay(on); } // Running the show void loop() { val = analogRead(potPin); // read value from pot (0-1023) burner= ((val*10)/1024); sevenSegWrite(burner); ssr(burner); }

ไม่มีความคิดเห็น:

แสดงความคิดเห็น