Hardware Reference
In-Depth Information
void setup()
{
pinMode(FAN, OUTPUT);
//Create a wire object for the temp sensor
Wire.begin();
//Set up the LCD's number of columns and rows
lcd.begin(16, 2);
//Make custom characters
lcd.createChar(0, degree);
lcd.createChar(1, fan_off);
lcd.createChar(2, fan_on);
//Print a static message to the LCD
lcd.setCursor(0,0);
lcd.print("Current:");
lcd.setCursor(10,0);
lcd.write((byte)0);
lcd.setCursor(11,0);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Set:");
lcd.setCursor(10,1);
lcd.write((byte)0);
lcd.setCursor(11,1);
lcd.print("C");
lcd.setCursor(15,1);
lcd.write(1);
}
//A debouncing function that can be used by multiple buttons
boolean debounce(boolean last, int pin)
{
boolean current = digitalRead(pin);
if (last != current)
{
delay(5);
current = digitalRead(pin);
}
return current;
}
void loop()
{
//Get the Temperature
Wire.beginTransmission(TEMP_ADDR); //Start talking
Wire.write(0); //Ask for register zero
Wire.endTransmission(); //Complete transmission
Wire.requestFrom(TEMP_ADDR, 1); //Request 1 byte
Search WWH ::




Custom Search