ArduinoADC
ArduinoADC
ArduinoADC
com
// Based on OpenMusicLabs previous works.
// pedalshield_uno_booster.ino: pressing the pushbutton_1 or 2 turns the volume up
or down.
#include <stdint.h>
//other variables
int input, vol_variable=100;
int counter=0;
unsigned int ADC_low, ADC_high;
Serial.begin(9600);
// setup ADC- configured to be reading automatically the hole time.
ADMUX = 0x60; // left adjust, adc0, internal vcc
ADCSRA = 0xe5; // turn on adc, ck/32, auto trigger
ADCSRB = 0x07; // t1 capture for trigger
DIDR0 = 0x01; // turn off digital inputs for adc0
// setup PWM - for more info about this config check the forum.
TCCR1A = (((PWM_QTY - 1) << 5) | 0x80 | (PWM_MODE << 1)); //
TCCR1B = ((PWM_MODE << 3) | 0x11); // ck/1
TIMSK1 = 0x20; // interrupt on capture interrupt
ICR1H = (PWM_FREQ >> 8);
ICR1L = (PWM_FREQ & 0xff);
DDRB |= ((PWM_QTY << 1) | 0x02); // turn on outputs
sei(); // turn on interrupts - not really necessary with arduino
}
void loop()
{
sendData(input);
//write the PWM output signal
/*OCR1AL = ((input + 0x8000) >> 8); // convert to unsigned, send out high byte
OCR1BL = input; // send out low byte*/
}