I am able to control my monitor and most other applications by giving serial input to python through arduino. Arduino code:
void setup()
{
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
Serial.begin(9600);
}
void loop()
{
if(digitalRead(2) == HIGH)
{
delay(5);
}
else
{
Serial.println("up");
}
if(digitalRead(3) == HIGH)
{
delay(5);
}
else
{
Serial.println("down");
}
if(digitalRead(4) == HIGH)
{
delay(5);
}
else
{
Serial.println("left");
}
if(digitalRead(5) == HIGH)
{
delay(5);
}
else
{
Serial.println("right");
}
if(digitalRead(6)== HIGH)
{
delay(5);
}
else
{
Serial.println("space");//orange
}
if(digitalRead(7)==HIGH)
{
delay(5);
}
else
{
Serial.println("nitro");//brown
}
}
Python code:
import serial
from pymouse import PyMouse
from pykeyboard import PyKeyboard
k = PyKeyboard()
ser = serial.Serial('COM7', 9600)
#sp.write("AT\r\n".encode('ascii'))
while True:
p=ser.readline()
print p
if ('up' in p):
k = PyKeyboard()
k.tap_key(k.up_key)
if ('down' in p):
k = PyKeyboard()
k.tap_key(k.down_key)
if ('right' in p):
k = PyKeyboard()
k.tap_key(k.right_key)
if ('left' in p):
k = PyKeyboard()
k.tap_key(k.left_key)
if ('space' in p):
k = PyKeyboard()
k.tap_key(k.space_key)
if ('nitro' in p):
k = PyKeyboard()
k.tap_key(k.enter_key)
My problem is that..I am not able to play games such as NFS and other similar games using these controls.. What should i do??