Variation. Temperature reading moves across x-axis with time, it is positioned in y-axis proportional to temperature as read.

Dependencies:   C12832_lcd LM75B mbed

Fork of app-board-LM75B by Chris Styles

Committer:
chapfohn
Date:
Wed Oct 23 04:16:10 2013 +0000
Revision:
5:b7c60e64fbf0
Parent:
4:e7ecb33e5806
Variation on parent program.; Temperature reading moves across x-axis of screen with time, its position in y-axis is proportional to the temperature as read.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:ce7a8546502b 1 #include "mbed.h"
chris 2:9e757151de9b 2 #include "LM75B.h"
chris 2:9e757151de9b 3 #include "C12832_lcd.h"
chapfohn 4:e7ecb33e5806 4 #include <math.h>
okano 0:ce7a8546502b 5
chris 2:9e757151de9b 6 C12832_LCD lcd;
chris 2:9e757151de9b 7 LM75B tmp(p28,p27);
okano 0:ce7a8546502b 8
chapfohn 5:b7c60e64fbf0 9 float temp=0; //Initialise temperature
chapfohn 5:b7c60e64fbf0 10 int i = 0; //Initialise counter
chapfohn 5:b7c60e64fbf0 11 int n = 129; //Set LCD screen width
chapfohn 4:e7ecb33e5806 12
chris 2:9e757151de9b 13 int main ()
okano 0:ce7a8546502b 14 {
chapfohn 5:b7c60e64fbf0 15 lcd.cls(); //Clear screen
chapfohn 5:b7c60e64fbf0 16 for (i = 0; i < n; i = i + 1) { //Move temperature reading across x-axis of the LCD screen
chapfohn 5:b7c60e64fbf0 17 temp = floor(tmp.read()); //Round down temperature reading
chapfohn 5:b7c60e64fbf0 18 lcd.locate(i,(32-(temp))); //Locate reading on LCD screen, 32- inverts position in y-axis
chapfohn 5:b7c60e64fbf0 19 lcd.printf("%.0f\n",temp); //Print the value
chapfohn 5:b7c60e64fbf0 20 wait(.1); //Pause
chapfohn 5:b7c60e64fbf0 21 if (i == (n-10)){ //Whether the x-axis position on LCD screen reached the maximum value
chapfohn 5:b7c60e64fbf0 22 i = 0; //If so reset x-axis position to 0
chapfohn 5:b7c60e64fbf0 23 lcd.cls(); //Clear screen
chapfohn 4:e7ecb33e5806 24 }
chapfohn 4:e7ecb33e5806 25 else
chapfohn 5:b7c60e64fbf0 26 ; //Otherwise continue the loop
chris 2:9e757151de9b 27 }
chapfohn 4:e7ecb33e5806 28 }
okano 0:ce7a8546502b 29
chapfohn 4:e7ecb33e5806 30