First, if this post is in the wrong area, I apologize for it and the moderator can move it.
I am relatively new to Arduino. I have using a starter kit to learn. There seems to be many good examples of hardware combinations for Uno. The Yun has good examples, but can be limited. After using the Uno to display information on LCD (type 1602A). I thought it would be great to do it remotely on Yun using the wifi network. It would be a good demonstration of web connectivity. After 32 characters are entered, the console receives a message showing the text on the display and how to clear it if there is an error.
I had some luck and managed to get everything to work. Here is the code for others use:
/*
USB Message Board Modified
for use with Yun board.
I am also trying to make the user input easier.
The circuit:
* digital pin 12 to LCD RS (pin 4)
* digital pin 11 to LCD Enable (pin 6)
* digital pin 10 to LCD D4 (pin 11)
* digital pin 9 to LCD D5 (pin 12)
* digital pin 8 to LCD D6 (pin 13)
* digital pin 7 to LCD D7 (pin 14)
* LCD R/W (pin 5) to ground
* 2.2K resistor from LCD VO (contrast, pin 3) to ground
* LCD VSS (pin 1) to ground
* LCD VDD (pin2) to +5 volts
* LCD A (pin 15) to +5 volts
* LCD K (pin 16) 330 ohm to ground, This limits current through Backlight LED
This does work with my module
Visble ASCII codes are between 20 and 126
To see the Console, pick your YUn's name and IP address in the Port menu
then open the Port Monitor. You can also see it by opening a terminal window
and typing ssh root@ yourYunsName.local 'telnet localhost 6571'
then pressing enter. When prompted for the password, enter it.
Legal Boiler Plate
Created 23 Dec. 2014 by Gregory Majewski
This example code is in the public domain without any warranty.
*/
// include the library code:
#include <LiquidCrystal.h>
#include <Console.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
//buffer for message, global used in both setup and loop
char messageText[] = "Arduino Rules ";
void setup() {
Bridge.begin(); // Initialize Bridge
Console.begin(); // Initialize Console
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.clear();
for (int i= 0; i < 32; i++) {
if (i == 16) {lcd.setCursor(0,1);} // go to second line
lcd.write(messageText[i]);
}
while(!Console); // Wait for the Console port to connect, do after initial message display
}
void loop() {
static int maxChars = 31;
static int maxOnrow = 15;
static int countChar = 0;
static int numLine =0;
if (Console.available() > 0) {
char inChar = Console.read();
if (inChar == '#') {//clear display character #
lcd.clear();
countChar = 0;
numLine = 0;
}
int posChar = countChar;
if (countChar > maxOnrow) { // go to second line
numLine = 1;
posChar = countChar - 16; // adjust position to be o to 15
}
if ((inChar > 31) && (inChar < 127) && (inChar != '#')) { //normal print characters minus #
messageText[countChar] = inChar;
lcd.setCursor(posChar, numLine);
lcd.write(inChar);
countChar ++;
}
if (countChar > maxChars) {
Console.println("");
Console.println("");
Console.println("No more characters can be displayed ");
Console.println("This the text that is displayed");
Console.println(messageText);
Console.println("If it is not right, clear display by typing # and try again");
countChar = 0; //zero countChar so only println once
numLine = 0;
// need to empty buffer of any extra characters
do {
inChar = Console.read();
} while (Console.available() > 0);
delay(750); //so typist can see error messages
}
}
}
Hopefully, this will be of use to somebody. Who knows, maybe there will be an “ultimate starter kit for the Yun”.