/* Sample program to read the analog value of the pin connected to the temperature sensor. * The temperature sensor on the Wytec EduBase board is connected pin 6. The value is sent to the * Serial monitor. and the upper 4 bits of the conversion result is also written to the LEDs. * The temperature sensor output is 10 mV per degree Celsius. The ADC converts 0-3.3V to 0-4095. * For ambient temperature of 70F, the output should be about 274. */ /* Tiva TM4C123 */ //const int LED[] = {PB_0, PB_1, PB_2, PB_3}; const int LED[] = {3, 4, 19, 38}; void setup() { Serial.begin(9600); Serial.println("Temperature sensor:"); // initialize LED for display for (int i = 0; i < 4; i++) { pinMode(LED[i], OUTPUT); } digitalGroupWrite(LED, 4, 0); } /* Tiva TM4C123 */ //const int temp = PE_5; const int temp = 6; void loop() { int tempValue; // read the voltage fromm ADC tempValue = analogRead(temp); // write it to the Serial monitor Serial.print(" temp sensor value = "); Serial.println(tempValue, DEC); digitalGroupWrite(LED, 4, tempValue >> 8); // and write it to the LEDs delay(100); } // write to a group of output pins void digitalGroupWrite(const int* group, int length, int data) { for (length--; length >= 0; length--) { digitalWrite(group[length], data & (1 << length) ? HIGH : LOW); } }