Saturday, April 18, 2015

LCD improvement

It is the first time that we used LCD in this course. In this improvement, we used timer, interrupt and show the current temperature on LCD screen. We used setCursor() function for the location of the data on the screen. We used analogRead function while reading the temperature value.
                                             Berrak Şişman and İlker Çam


#include 
#include 


const int temperaturePin = 0;
LiquidCrystal lcd(12,11,5,4,3,2);
volatile int readEvent = 0;
void setup()
{

  lcd.begin(16, 2);
  lcd.clear();
  lcd.print("Read Serial!");
  Serial.begin(9600);
  Timer1.initialize(8000000); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
  Timer1.attachInterrupt(setFlag); // attach the service routine here
}

void loop()
{
    if(readEvent == 2){
      lcd.setCursor(0,1);
      lcd.print("Interrupt Calling");
      Serial.println("Interrupt Calling..");
      getTemp();
      readEvent = 0;
    }
}

void setFlag(){
  readEvent++;
}

void getTemp()
{
  float voltage,degreesC;
  voltage = (analogRead(temperaturePin) * 0.004882814);
  degreesC = (voltage - 0.5) * 100.0;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temperature : ");
  lcd.print(degreesC);
}

1 comment:

  1. Wynn Palace - Casino, Restaurants - MapYRO
    Find Wynn 1xbet korean Palace Casino, Restaurants in 광주광역 출장마사지 Las Vegas, NV 이천 출장샵 and other nearby 당진 출장마사지 hotels. Wynn Palace. Wynn Las 경주 출장샵 Vegas, NV.

    ReplyDelete