int analogRead(uint8_t pin)
{
  #if defined( CORE_ANALOG_FIRST )
    if ( pin >= CORE_ANALOG_FIRST ) pin -= CORE_ANALOG_FIRST; // allow for channel or pin numbers
  #endif

  // fix? Validate pin?

  ADC_SetVoltageReference( analog_reference );
  ADC_SetInputChannel( pin );

  ADC_StartConversion();

  while( ADC_ConversionInProgress() );

  return( ADC_GetDataRegister() );
}
ADConverter::ADConverter() {
	ADC_PrescalerSelect(ADC_PRESCALER);
	ADC_SetVoltageReference(ADC_Reference_External);
	ADC_Enable();
	ADC_StartConversion();
}