An example of using the Arduino board to receive data from the Console on the Arduino Yún. In this case, the Arduino board turns the on-board LED connected to digital pin 13 on when it receives the character 'H', and off when it receives the character 'L'.
The Console, based on Bridge, enables you to send information from the Yún to a computer just as you would with the serial monitor, but wirelessly. It creates a secure connection between the Yún and your computer via SSH.
To see the Console, make sure your Yún and computer are in the same wireless network. Pick your Yún's name and IP address in the Port menu in the Arduino Software (IDE) then open the Port Monitor. You can also see it by opening a terminal window and typing
ssh root@ yourYúnsName.local 'telnet localhost 6571' then pressing enter. When prompted for the password, enter it.
There is no circuit for this example.
Include the Console library, which inherits from Bridge.
Create variables and name the pin to write to, and another one to store the incoming byte from the Console.
setup() initialize the Bridge and Console, and wait for a connection to the Console port.
Once connected, print out some basic instructions to the Console window with
Console.println() and set the LED pin as an output.
loop(), check to see if there is information from the Console. If there is, read the oldest byte in the buffer and echo it back to the Console window.
If the incoming byte is a capital "H", turn the LED on, if it is a "L", turn the LED off.
The complete sketch is below :
Last revision 2015/08/11 by SM