// temp is the variable to hold the input from analog0 int temp = 0 ; // the LED is a multiplexed module // anode1 is the ones digit // anode10 is the tens digit volatile int anode1=12; volatile int anode10=13; volatile int anode=0; volatile int lowdisp=0; volatile int highdisp=0; // these are the individual segments // I just found it easier to visual and map out // as a discrete process byte blank = 0b11111111; byte seg_a = 0b11111110; byte seg_b = 0b11111101; byte seg_c = 0b11111011; byte seg_d = 0b11110111; byte seg_e = 0b11101111; byte seg_f = 0b11011111; byte seg_g = 0b10111111; // and then convert the segments into numbers // this could have been combined into a single // process, but as above, I found it better for // visualization byte one = seg_b & seg_c; byte two = seg_a & seg_b & seg_g & seg_e & seg_d; byte three = seg_a & seg_b & seg_g & seg_c & seg_d; byte four = seg_f & seg_b & seg_g & seg_c; byte five = seg_a & seg_f & seg_g & seg_c & seg_d; byte six = seg_a & seg_f & seg_g & seg_c & seg_d & seg_e; byte seven = seg_a & seg_b & seg_c; byte eight = seg_a & seg_b & seg_c & seg_d & seg_e & seg_f & seg_g; byte nine = seg_a & seg_b & seg_c & seg_g & seg_f; byte zero = seg_a & seg_b & seg_c & seg_d & seg_e & seg_f; void setup() { // use the 1.1v internal reference of the Mega168 analogReference(INTERNAL); // set the LED modes and make sure they are blank pinMode (anode1,OUTPUT); pinMode (anode10,OUTPUT); digitalWrite(anode1,LOW); digitalWrite(anode10,LOW); // these correspond to digital0-7 // digital 0 and digitial 1 are normally used for // usart communication, so we cannot use the hardware // serial port now DDRD = 0b01111111; PORTD=blank; // the temperature is read during an interrupt loop // I am using timer/counter1 for no other reason than // it is there. this is in overflow mode, on a fairly // fast prescaler, since it is a 16-bit timer TCCR1A=0; TCCR1B = (0<