# A test for sending CODE

#### Camerart

##### Coder
Hi,
Firtst post to send a practice CODE

Failed first try.
Cheers, C.

Hi again,
I couldn't get the </> sign to work!
C

Hey mate, what are you trying to do?

Hey mate, what are you trying to do?
Hi S,
I was failing at posting CODE using </>, it appears to be working now.

My initial question was going to be regarding READing of a peripheral registers of a Compass.
which appears to be getting the odd wrong READing, making the calculated DEGREES slightly wrong, so in the past I've been averaging. I think now that my seeting are a bit wrong.

I'll save you reading the data sheet, plus understanding Oshonsoft BASIC, which is what I use, and I've been given lots of things to try by an electrical forum.
Cheers, C
Code:
``````A TEST ONLY!!!!!!!!!!!!!!!!!!!!!!!!!!

'ALTITUDE TEMP CALC
Proc calca()  'ALTMTR BMP280
'Calculate temperature
var1 = ((adc_t / 16384 - (dig_t1 / 1024))) * dig_t2
var2 = (((adc_t) / 131072 - (dig_t1) / 8192) * (adc_t / 131072 - dig_t1 / 8192) * dig_t3)
t_fine = var1 + var2
tp = (var1 + var2) / 5120
'Calculate pressure
var1 = t_fine / 2 - 64000
var2 = var1 * var1 * dig_p6 / 32768
var2 = var2 + var1 * dig_p5 * 2
var2 = var2 / 4 + dig_p4 * 65536
var1 = ((dig_p3) * var1 * var1 / 524288 + dig_p2 * var1) / 524288
var1 = (1 + var1 / 32768) * dig_p1
pr = 1048576 - adc_p
pr = (pr - (var2 / 4096)) * 6250 / var1
var1 = dig_p9 * pr * pr / 2147483648
var2 = pr * dig_p8 / 32768
pr = pr + (var1 + var2 + dig_p7) / 16
End Proc``````