Console Pixel example from IDE:

#include <Console.h>
const int ledPin = 13; // the pin that the LED is attached to
char incomingByte;      // a variable to read incoming Console data into
void setup() {
  Bridge.begin();   // Initialize Bridge
  Console.begin();  // Initialize Console
  while (!Console);   // Wait for the Console port to connect
  Console.println("type H or L to turn pin 13 on or off");  
  pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:
}
void loop() {
  // see if there's incoming Console data:
  if (Console.available() > 0) {
    incomingByte = Console.read();  // read the oldest byte in the Console buffer:
    Console.println(incomingByte);
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);  // if it's a capital H (ASCII 72), turn on the LED:
    }
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);   // if it's an L (ASCII 76) turn off the LED:
    }
  }
}

Test above code:

ssh root@ yourYunsName.local 'telnet localhost 6571'

type "H" will be on, type "L" will be off.

Now we need redirect port 8888 of Arduino Yun ip (i.e. 192.168.0.102) to localhost 6571.

opkg update
opkg install socat
(socat TCP-LISTEN:8888,fork TCP:127.0.0.1:6571) &

Now you should be able access Yun from PC

telnet 192.168.0.102 8888

type "H" will be on, type "L" will be off.

Comments powered by CComment