Hello All,
I am working on writing a microcontroller (Attiny24) program using C++ and programmer's notepad. When the ADC performs a conversion, the microcontroller stores the value in the ADCH and ADCL registers. These are both 8-bit registers. The ADC has 10 bits of resolution. Currently I'm taking the values from both registers and putting it into one 16-bit variable. Once I have the 16-bit binary value from the ADC (lets call this variable 16_bit_result), I would like to multiply it by .02 and store this value in another variable (Result_of_16_bit_multiplied_by_pointzerotwo). Can I just perform the following?
Create new variable - double Result_of_16_bit_multiplied_by_pointzerotwo
then perform the following calculation
Result_of_16_bit_multiplied_by_pointzerotwo = 16_bit_result*.02
Or do I need to do any typecasting?
I am working on writing a microcontroller (Attiny24) program using C++ and programmer's notepad. When the ADC performs a conversion, the microcontroller stores the value in the ADCH and ADCL registers. These are both 8-bit registers. The ADC has 10 bits of resolution. Currently I'm taking the values from both registers and putting it into one 16-bit variable. Once I have the 16-bit binary value from the ADC (lets call this variable 16_bit_result), I would like to multiply it by .02 and store this value in another variable (Result_of_16_bit_multiplied_by_pointzerotwo). Can I just perform the following?
Create new variable - double Result_of_16_bit_multiplied_by_pointzerotwo
then perform the following calculation
Result_of_16_bit_multiplied_by_pointzerotwo = 16_bit_result*.02
Or do I need to do any typecasting?