This example for the Arduino Yún demonstrates how to print to the Console by generating a table of characters and their ASCII values in decimal, hexadecimal, octal, and binary. For more on ASCII, see asciitable.com.
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.
When your Yún and computer are on the same network, you can find the Yún in the Tools>Ports menu item in the Arduino Software (IDE).
There is no circuit for this example.
Include the Console library, which inherits from Bridge.
Create a variable that will hold the value to print out to the Console window. ASCII characters of values 32 and below are invisible, so initialize the variable with a value of 33 (which corresponds to "!" ).
int byte = 33;
setup(), initialize the Bridge and Console, and wait for the port to open. Once a connection has been made, print out a small bit of information describing what is going to follow :
loop(), you will print the value in a number of different formats.
To see the ASCII value of the variable, you can write the byte with
Console.write(). The Console interprets all bytes as ASCII characters.
Console.print() prints the value as a string of ASCII encoded decimals by default.
Console.println() can also send strings to the Console window that represent hexadecimal, octal, and binary number values with the appropriate modifier.
Console.println() will add newline and carriage return characters to the string, creating a line break in the Console window.
In this example, you're only printing out the alphanumeric characters that appear on a USA keyboard, so there's no need to print any values past 126. To make sure all the data gets sent before stopping the sketch, make a call to
If the sketch hasn't printed out all the values, increment
thisByte before running through the
The complete sketch is below :
Last revision 2015/08/11 by SM