/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */


int ADC_VAL0 = A0;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the ADC_VAL0's pin an input:
  //pinMode(ADC_VAL0, INPUT);

 analogReference(INTERNAL);
 //to find where arduino does this, grep -r analogReference in Arduino install folder
 //cryptic shit though
 //so instead, just fprint the register before and after the change. much more intuitive.

  //do it manually...


  
  //this doesn't work
  //ADMUX = (0 << REFS1) | (0 << REFS0) ;

  //this doesn't work
  //ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX0);

  //this doesn't work
  //ADMUX = ADMUX | 0b11001110;

  //this doesn't work
  //ADMUX = (1 << REFS1) | (1 << REFS0) ;

 //this also doesn't work
  //ADMUX |= (1 << REFS0);
  //ADMUX |= (1 << REFS1);
  
  //search engines have been fucked over with endless forum debates, hopeless. a blog post guide would suffice.

  //even this doesn't work. why... it should work. must be wiring code breaking things. give up for now.
  //ADMUX = ADMUX | 0b11000000;


  
  
  
  
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int ADCVAL0_State = analogRead(ADC_VAL0);
  // print out the state of the button:
  Serial.println(ADCVAL0_State);
  delay(10000);        // delay in between reads for stability


  //Trying to debug why I cant change a bit in a register. fucking wiring. fuck search engines.
  //int dog = ADMUX;
  //Serial.println(ADMUX,BIN);
}



