connect an Arduino Yun to a mac via wifi to send keys

hi everyone I want to know if is possible to connect an Arduino Yun to a mac via wifi - I’m doing a an interface in UNITY and need to send 4 keys (W A S and D) now i’m using an Arduino Leonardo and works perfect but Being Connected via USB is a little bit annoying . I just got an Arduino Yun but I can get or understand references to see if is possible or not . Can anyone help tks tks tks.

which side of the Arduino Yun? the ATmega side of the Atheros side? there is nothing stopping you writing a service on the Linio portion of the Yun that your mac can connect to over WiFi. there is also nothing stopping you putting a WiFi shield on the ATmega portion of the Yun and have that connect to your mac.

you need to explain more about what you need for anyone to give you a more concrete answer - just one thing to know right off the bat: the WiFi/ethernet of the Linio side is not usable directly from the ATmega side.

there is 4 sensors in a room the sensors right now are connected with wires on the room so they can be connected to the Arduino Leonardo. The sensors are only printing the 4 Keys (W A S and D ) each time they are press and animation launches - so I’m using the Arduino as a keyboard .

When I try to connect the Arduino Yun to the mac via the the serial monitor 115200 I can’t convert the code to keys ( If you can give me any reference on where to find I will really appreciated ) (I’m an artist I work all the time with Arduino but I don’t really understand the middle part Atheros… (any reference to where to find a possible solution ) thanks

ok; so your sensors are connected to GPIO's on the ATmega side and as a result you want to simulate pressing keys WAS and D.

is there a reason you chose the Arduino Yun for this if you are only using the USB portion of the device? in any event; if you want to receive the information over the USB port on the mac, then you should be able to print "WASD" on the console using the standard Serial::print() functions. if you can see the information within the Serial monitor - then you are a step in the right direction.

once you have this; your next step would be to replace the Serial Monitor with your own program that connects to the Serial port (over USB) directly to receive the information from the Arduino device. the alternative is to use the Bridge on the Arduino Yun to send the information to the Linio portion and then utilize the WiFi/ethernet connection directly to the mac.. but, you'll find latency may be an issue here.

I already did the first part - and works amazing but now what I’m trying to do is send them via wifi but I can’t make that the serial print works over wifi - and the reference on internet on the atheros side is minimum - I can't make the keys to appear on the serial monitor and I don't know if the problem is that the Arduino in not recognized by the computer or that the connection via serial monitor is inexistent.

SantiagoLeal: I already did the first part - and works amazing but now what I’m trying to do is send them via wifi but I can’t make that the serial print works over wifi - and the reference on internet on the atheros side is minimum - I can't make the keys to appear on the serial monitor and I don't know if the problem is that the Arduino in not recognized by the computer or that the connection via serial monitor is inexistent.

The part that you are missing is that while the AVR part is more or less compatible with an Arduino Leonardo, the docs clearly state that you can not the primary serial port for any outside communication from your sketch as this serial port is used for the bridge connection between the Artheros (DD-WRT/Linux) part and the AVR/Leonardo part. Check the info about the Yun on this web site about the alternative serial communication, the forum is also full of post from people that have the very same problem and the solution that they had to apply...

Ralf

You can write a script that runs in the linux side that receive data from the sketch via the Bridge class ( http://arduino.cc/en/Reference/YunBridgeLibrary ) and then the script sends data over wifi. To send data over wifi you can use a python script. Python has a lot of libraries that give you TCP/IP connection.

Using yun wifi to connect to your mac implies that you mac is acting as a server, listening to connection to your mac IP address on some port
If all this is true, you can use YunClient to connect to your mac. See http://arduino.cc/en/Reference/YunClientConnect
Once you’re connected, you can print those 4 chars