Exemplo n.º 1
0
int main(void) {

  float voltage;

  // -------- Inits --------- //
  initUSART();
  printString("\r\nDigital Voltmeter\r\n\r\n");
  initADC();
  setupADCSleepmode();

  // ------ Event loop ------ //

  while (1) {

    voltage = oversample16x() * VOLTAGE_DIV_FACTOR * REF_VCC / 4096;
    printFloat(voltage);
    /*  alternatively, just print it out:
     *  printWord(voltage*100);
     *  but then you have to remember the decimal place
     */
    _delay_ms(500);

  }                                                  /* End event loop */
  return 0;                            /* This line is never reached */
}
Exemplo n.º 2
0
int main(void) {

	float voltage1;
	float voltage2;
	float res1;
	float res2;
	// -------- Inits --------- //
	initUSART();
	setupADCSleepmode();
	printString("\r\nDigital Voltmeter\r\n\r\n");
	

	// ------ Event loop ------ //
  
	while (1) {

		initADC(0);
		voltage1 = oversample16x();
		printString("Thermistor 1:\r\n");
		printFloat(voltage1);
		//printVoltage(voltage1);
		res1 = printThermRes(voltage1);
		printTemp(res1);
		printString("\r\n");
		
		_delay_ms(100);

		initADC(1);
		voltage2 = oversample16x();
		printString("Thermistor 2:\r\n");
		printFloat(voltage2);
		//printVoltage(voltage2);
		res2 = printThermRes(voltage2);
		printTemp(res2);
		printString("\r\n");
		_delay_ms(2500);
		
	}                                                  /* End event loop */
	return (0);                            /* This line is never reached */
}