Hello!
(I haven't been here in a very long while.)
Anyway I have this particular sketch:
void setup()
{
Serial.begin(9600);
backlightOn();
}
void loop()
{
selectLineOne();
Serial.print(millis());
selectLineTwo();
Serial.print(millis()/2);
delay(100);
}
void selectLineOne(){ //puts the cursor at line 0 char 0.
Serial.write(0xFE); //command flag
Serial.write(128); //position
delay(100);
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
Serial.write(0xFE); //command flag
Serial.write(192); //position
delay(100);
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
if (position<16){ Serial.write(0xFE); //command flag
Serial.write((position+128)); //position
}else if (position<32){Serial.write(0xFE); //command flag
Serial.write((position+48+128)); //position
} else { goTo(0); }
delay(100);
}
void clearLCD(){
Serial.write(0xFE); //command flag
Serial.write(0x01); //clear command.
delay(100);
}
void backlightOn(){ //turns on the backlight
Serial.write(0x7C); //command flag for backlight stuff
Serial.write(157); //light level.
delay(100);
}
void backlightOff(){ //turns off the backlight
Serial.write(0x7C); //command flag for backlight stuff
Serial.write(128); //light level for off.
delay(100);
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.write(0xFE);
}
It compiles and runs for the Uno, but it was originally tried out on the one from 2009, which is this guy:
Arduino Duemilanove.
And it does seem to compile and run for the Arduino MKR1000 device.
void setup()
{
Serial.begin(9600);
backlightOn();
}
void loop()
{
selectLineOne();
Serial.print(millis());
selectLineTwo();
Serial.print(millis()/2);
delay(100);
}
void selectLineOne(){ //puts the cursor at line 0 char 0.
Serial.write(0xFE); //command flag
Serial.write(128); //position
delay(100);
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
Serial.write(0xFE); //command flag
Serial.write(192); //position
delay(100);
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
if (position<16){ Serial.write(0xFE); //command flag
Serial.write((position+128)); //position
}else if (position<32){Serial.write(0xFE); //command flag
Serial.write((position+48+128)); //position
} else { goTo(0); }
delay(100);
}
void clearLCD(){
Serial.write(0xFE); //command flag
Serial.write(0x01); //clear command.
delay(100);
}
void backlightOn(){ //turns on the backlight
Serial.write(0x7C); //command flag for backlight stuff
Serial.write(157); //light level.
delay(100);
}
void backlightOff(){ //turns off the backlight
Serial.write(0x7C); //command flag for backlight stuff
Serial.write(128); //light level for off.
delay(100);
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.write(0xFE);
}
Since the Uno and the Duemilanove both have the serial port at the 0 and 1 position and the MKR1000 repositioned the pins to 14 and 13, should it be possible to simply switch pin positions from the 1 position on the Uno to 13 position on the MKR1000?
Obligatory reference:
That original came from this page on main Arduino site:
Sparkfun LCD serial displays
Ideally I am leaning towards using the entire Sparkfun LCD serial display provide programming status from the MKR1000.