The present code implements and checks the current temperature.

Dependencies:   TMP102 mbed

Dependents:   Squash_Project

Fork of 2645_I2C_TMP102 by Craig Evans

Committer:
bonnyngangu
Date:
Wed May 11 14:43:59 2016 +0000
Revision:
3:5d33e4bd4433
Parent:
main.h@2:0047b6c36b3e
Light pattern expressing hot and cold temperature.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eencae 0:21a200b880d7 1 /*
bonnyngangu 2:0047b6c36b3e 2 Joystick_Project
bonnyngangu 2:0047b6c36b3e 3 Bonny Ngangu
bonnyngangu 2:0047b6c36b3e 4 6 March 2016
bonnyngangu 2:0047b6c36b3e 5 (c) Bonny Ngangu, University of Leeds, Feb 2016
eencae 0:21a200b880d7 6
eencae 0:21a200b880d7 7 */
eencae 0:21a200b880d7 8
eencae 0:21a200b880d7 9 #include "mbed.h"
eencae 1:dd5fb735acf1 10 // include the library header, ensure the library has been imported into the project
eencae 1:dd5fb735acf1 11 #include "TMP102.h"
bonnyngangu 2:0047b6c36b3e 12 #include "N5110.h"
bonnyngangu 2:0047b6c36b3e 13
eencae 0:21a200b880d7 14
eencae 1:dd5fb735acf1 15 // Create TMP102 object
eencae 1:dd5fb735acf1 16 TMP102 tmp102(I2C_SDA,I2C_SCL);
eencae 0:21a200b880d7 17 // UART connection for PC
eencae 0:21a200b880d7 18 Serial pc(USBTX,USBRX);
eencae 0:21a200b880d7 19
eencae 0:21a200b880d7 20 // K64F on-board LEDs
eencae 0:21a200b880d7 21 DigitalOut r_led(LED_RED);
eencae 0:21a200b880d7 22 DigitalOut g_led(LED_GREEN);
eencae 0:21a200b880d7 23 DigitalOut b_led(LED_BLUE);
bonnyngangu 2:0047b6c36b3e 24
eencae 0:21a200b880d7 25 // K64F on-board switches
eencae 0:21a200b880d7 26 InterruptIn sw2(SW2);
eencae 0:21a200b880d7 27 InterruptIn sw3(SW3);
eencae 0:21a200b880d7 28
eencae 0:21a200b880d7 29 // error function hangs flashing an LED
eencae 0:21a200b880d7 30 void error();
eencae 0:21a200b880d7 31 // setup serial port
eencae 0:21a200b880d7 32 void init_serial();
eencae 0:21a200b880d7 33 // set-up the on-board LEDs and switches
eencae 0:21a200b880d7 34 void init_K64F();
bonnyngangu 2:0047b6c36b3e 35 void printString();
eencae 0:21a200b880d7 36
eencae 0:21a200b880d7 37 void init_serial() {
eencae 0:21a200b880d7 38 // set to highest baud - ensure terminal software matches
eencae 0:21a200b880d7 39 pc.baud(115200);
eencae 0:21a200b880d7 40 }
eencae 0:21a200b880d7 41
eencae 0:21a200b880d7 42 void init_K64F()
eencae 0:21a200b880d7 43 {
eencae 0:21a200b880d7 44 // on-board LEDs are active-low, so set pin high to turn them off.
eencae 0:21a200b880d7 45 r_led = 1;
eencae 0:21a200b880d7 46 g_led = 1;
eencae 0:21a200b880d7 47 b_led = 1;
eencae 0:21a200b880d7 48
eencae 0:21a200b880d7 49 // since the on-board switches have external pull-ups, we should disable the internal pull-down
eencae 0:21a200b880d7 50 // resistors that are enabled by default using InterruptIn
eencae 0:21a200b880d7 51 sw2.mode(PullNone);
eencae 0:21a200b880d7 52 sw3.mode(PullNone);
bonnyngangu 2:0047b6c36b3e 53 }