Hi,
i read this tutorial: http://codeandlife.com/2012/01/22/avr-a ... al-part-1/ , and the same author wrote a How-To for making an USB-Keyboard via the HID-class, which worked wonderful for me Now i´m wondering how to get the output of my ADC to a joystick-axis recognized in the windows "USB- and Gamecontrollers"-dialogue... Thanks in advance,
Slot
Joystick-axis
Re: Joystick-axis
Its a bit to get used to but not too hard. This is using the ADC's on an atmega 168/328
the init would be
and you would read in to a report like so - natural your math will be different.
Code: Select all
//voltage reader.
#define ADC_VREF_TYPE 0x40
static int read_adc(unsigned char adc_input)
{
ADMUX=adc_input|ADC_VREF_TYPE;
_delay_us(150);
ADCSRA|=0x40; // Start the AD conversion
while ((ADCSRA & 0x10)==0);// Wait for complete
ADCSRA|=0x10;
return ADCW;
}
the init would be
Code: Select all
ADMUX=0x1;//ADC init
ADCSRA=0x83;
and you would read in to a report like so - natural your math will be different.
Code: Select all
reportBuffer[1]= (read_adc(0)/3 + 200);//pc0
reportBuffer[2]= (read_adc(1)/3 + 200)*-1;//pc1