const int xP = 11;
const int yP = 12;void setup() {
// put your setup code here, to run once:
Serial.begin(9600);pinMode(xP, INPUT);
pinMode(yP, INPUT);}
void loop() {
// put your main code here, to run repeatedly:
int px, py;
int ax, ay;px = pulseIn(xP, HIGH);
py = pulseIn(yP, HIGH);ax = ((px / 10) - 500) * 8;
ay = ((py / 10) - 500) * 8;Serial.print(ax);
Serial.print("\t");
Serial.print(ay);
Serial.println();delay(100);
}
The code is as above and the circuit diagram is exactly this
