Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint8_t temperature[2];
- int8_t digit;
- uint16_t decimal;
- char str_temp[10];
- if (read)
- {
- read = 0;
- ow_reset();
- ow_write_byte(0xCC); // skip ROM
- ow_write_byte(0xBE); // read scratchpad
- temperature[0] = ow_read_byte();
- temperature[1] = ow_read_byte();
- ow_reset();
- digit = temperature[0] >> 4;
- digit |= (temperature[1] & 0x7) << 4;
- decimal = temperature[0] & 0xf;
- decimal *= 625;
- }
- if (transmit)
- {
- transmit = 0;
- cmd = 0;
- sprintf(str_temp, "%+d.%04u", digit, decimal);
- uart_print(str_temp);
- uart_nwln();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement