onde o valor 0x00 do stick, indica a posicao toda abaixo, o valor 0x80 indica o botao solto no meio e 0xFF indica a posicao toda para cima. Quando o joystick nao esta em modo analogico com o led vermelho apagado, estes botoes analogicos correspondem a:Analogico esquerdo => esquerda, direita, cima e baixo Analogico direito => quadrado, circulo, triangulo e X. O mapa do botoes esta listado abaixo. Recomendo visitar as paginas abaixo, pois dao uma visao mais detalhada de todos comando e sinais envolvidos. usei a interface SPI para comunicar-se com o joystick. Pode ser usado controle tambem sem fios.usei clock do atmega162 de 8MHz.English:This project controls 4 motors with dc ps2 joystick with two bridges L298h and ATMEGA162. the joystick is initialized to analog mode and lock analogic button . The software constantly reads data from joystick and stores in 6 bytes, which are the dig_1 to dig_6. The dig_1 and dig_2 and contains reading the joystick buttons. These buttons are used to control 4 motors through two bridges H L298. The bytes dig_3 to dig_6 contens reading the analog buttons, and ranges 0x00 to 0xFF, where 0x00 indicates the LOW/LEFT position, 0x80 indicates the MIDDLE and 0xFF indicates the UP/RIGHT. When red led is off, the LEFT STICK is same control the digital buttons left, right, up, and RIGHT STICK same digital buttons square, circle, triangle and x. The map of the buttons are listed below. I recommend visiting the links below, they give a more detailed overview of all command and joystick signals. This version uses the SPI inteface to communicate with the joystick.wireless control can be used .Use the clock of the 8MHz, at 16MHz, initialization fails sometimes, and not turn the red led analog mode.Controle em modo analogico, led vermelho ligadoAnalog control with Red LED on BYTE CMND DATA 01 0x01 idle 02 0x42 0x73 03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 04 idle data SLCT JOYR JOYL STRT UP RGHT DOWN LEFT 05 idle data L2 R2 L1 R1 /\ O X |_| 06 idle data Right Joy 0x00 = Left 0xFF = Right 07 idle data Right Joy 0x00 = Up 0xFF = Down 08 idle data Left Joy 0x00 = Left 0xFF = Right 09 idle data Left Joy 0x00 = Up 0xFF = Downlinks de referencia / reference linkshttp://store.curiousinventor.com/guides/PS2http://www.gamesx.com/controldata/psxcont/psxcont.htmhttp://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=1053985Circuito completo.Programa em C para codevisionavrsource code to codevisionavr//******************************************************// sistema de leitura do joystick playstation 2//read joy ps2 avr atmega162 a 16MHzz, divide clock 16/2= 8MHz/// usa a SPI para le bytes do controle// programa para analogico e trava botao mode// use spi interface and lock button mode//******************************************************#include <mega162.h>#include <delay.h>#include <stdio.h>#include <stdlib.h>#define SSD 1 // Delay for how long SS stays high before going low again for the next byte trransfer#define SS PORTB.4 // Slave/Chip Select line#define cs1 PORTB.2#define cs2 PORTB.3#define left PORTA.0#define right PORTA.1#define up PORTA.2#define down PORTA.3#define tri PORTA.4#define axi PORTA.5#define qua PORTA.6#define cir PORTA.7unsigned char dummy,modo,status,dig_1,dig_2,dig_3,dig_4,dig_5,dig_6; // For dummy readstypedef unsigned char byte;byte SPI_TxRx(byte data);//****************************************** // inicializa joystick modo analogico e trava botao modo// init joystick and