Mark T - I got the idea that arduino 5V pins can power other devices by the fact all the tutorials told me to plug then in. Since the power supply is 5V I can't power off that as I need 5.. So I think I am missing the point of your advice. Are you saying I should be grounding to the power supply instead of direct from the board?
Here is the code configuring the pins:
#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "max6675.h"
/-----( Declare Constants )-----/
static float gTempLast;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
byte newChar1[8] = {
B00100,
B01110,
B10101,
B00100,
B00100,
B00100,
B00100,
B00100
};
byte newChar2[8] = {
B00100,
B00100,
B00100,
B00100,
B00100,
B10101,
B01110,
B00100
};
int thermoDO = 6;
int thermoCS = 5;
int thermoCLK = 4;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
// use Arduino pins - but at the moment only use VCC and Ground Pins
int vccPin = 3;
int gndPin = 2;
//Potentiometer Stuff
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int potValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
Serial.begin(9600);
lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines and turn on backlight
// use Arduino pins
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
//LCD Create the Chars
lcd.createChar(1, newChar1);
lcd.createChar(2, newChar2);
// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on */
gTempLast = 999; //impossible start value
//-------- Write characters on the display ----------------
// NOTE: Cursor Position: CHAR, LINE) start at 0
lcd.setCursor(1,0); //Start at character 1 on line 0
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
lcd.setCursor(0,0); //home
float currentTemp0 = thermocouple.readCelsius();//DEBUG
float currentTemp1 = thermocouple.readFahrenheit();//DEBUG
float fTempDiff = currentTemp0-gTempLast; //between this read and the last
if (fTempDiff != 0){ // gone up or gone down since last time
//Serial.println (currentTemp0);
if (currentTemp0 > gTempLast)
lcd.write(1); //up arrow
else
lcd.write(2); //down arrow
lcd.print(" "); //clear previous char
lcd.print(fTempDiff);
//Serial.print(fTempDiff);DEBUG
}
else {
lcd.setCursor(0,0);
lcd.print("<> "); //overwrite the first line
// Serial.println ("<>");DEBUG
}
// read the analog in value:
potValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(potValue, 0, 1023, 3600, 1);
// change the analog out value:
//analogWrite(analogOutPin, outputValue); //Fade an LED if required OR control motor
lcd.setCursor(0,1); //goto second line
lcd.print((char)223);
lcd.print("C: ");
lcd.print(currentTemp0);
lcd.print(" ");
lcd.print((char)223);
lcd.print("F: ");
lcd.print(currentTemp1);
lcd.setCursor(0,3);
lcd.print(potValue);
lcd.print(" ");//clear previous char
gTempLast = currentTemp0;
delay(10000);
}