Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //for Arduino bud toaster, battery powered. more comments to come!
- #include "nokia_3310_lcd.h"
- #include "avr_bmp.h"
- #include<stdlib.h>
- #include <PID_v1.h>
- //Define PID Variables
- double Setpoint, Input, Output;
- //Specify the links and initial tuning parameters
- PID myPID(&Input, &Output, &Setpoint,4,0.1,5, DIRECT);
- #include <MAX6675.h>
- int thermoDO = 4;
- int thermoCS = 3;
- int thermoCLK = 2;
- MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
- Nokia_3310_lcd lcd=Nokia_3310_lcd();
- char string1[]="0000";
- void setup()
- {
- Serial.begin(9600);
- //initialise LCD
- lcd.LCD_3310_init();
- lcd.LCD_3310_clear();
- Input = thermocouple.readCelsius();
- Setpoint = 190;
- //turn the PID on
- myPID.SetMode(AUTOMATIC);
- //write initial describers to the LCD
- lcd.LCD_3310_write_string(0, 0, " Cur Set", MENU_NORMAL );
- lcd.LCD_3310_write_string(35, 4, "@C", MENU_NORMAL);
- }
- void loop()
- {
- //PID stuff:
- Input = thermocouple.readCelsius();
- myPID.Compute();
- int out = map(Output, 0, 255, 0, 100);
- analogWrite(5,out);
- //write temp to the LCD
- dtostrf(Input,3,0,string1);
- lcd.LCD_3310_write_string_big(0, 1, string1, MENU_NORMAL);
- dtostrf(Setpoint,3,0,string1);
- lcd.LCD_3310_write_string_big(42, 1, string1, MENU_NORMAL);
- dtostrf(out,4,1,string1);
- lcd.LCD_3310_write_string(0, 4, string1, MENU_NORMAL);
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement