1

I'm trying to simply program an Arduino trinket to display some text on an LCD display.

I'm basically trying to follow this, except connect it to a Trinket rather than an Arduino Uno. The background color of the LCD display is changing as expected from the loop function in my Arduino code, but it's just displaying some o's and arrow's for text on the LCD display.

I'm new to Arduino's (and EE in general), but am a computer programmer.

What am I doing wrong that the sample code in the above link doesn't print text on my LCD display?

enter image description here

enter image description here

enter image description here

migrated from electronics.stackexchange.com May 19 '16 at 11:54

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • If the code partially works (screen is cleared and starts to print) are you sure your closing syntax (; }) and delimiters are in place? If the BG 'for' loop is working, what is blocking the rest of the code? One tiny syntax error will do that. – Sparky256 May 19 '16 at 4:45
  • Since you mention the target board is an "Arduino Trinket" instead of "Arduino Uno", could there be some difference in how the LCD display was wired? In other words the pin assignments may be different than expected in the example code. As a diagnostic you could try the LCD Hello World example (under File - Examples - LiquidCrystal - HelloWorld if you're using the Arduino IDE). If that doesn't work then you need to find the schematic for your board, determine which LCD pin connects to which ATmega328 pin, and then which "Arduino" pin number that is, so you can update the source code. – MarkU May 19 '16 at 5:39
  • Disregard my above comment; I misinterpreted the question; usually Arduino + LCD means an HD44780 LCD connected directly to the ATmega328. That's not the case here. You actually have a serial (RS232-like) connection between two devices. So the real problem is more likely incorrect baud rate, or some other RS232 protocol related issue. – MarkU May 19 '16 at 5:44
  • Looking at the first photo, was there some reason you connected the white serial data wire to the trinket's "Digital #0" instead of "Digital #2" as in the example code? Be aware that on Arduino UNO, digital #0 is used for serial receive, so may cause problems to use that pin for a serial transmit. It looks like Digital #2 is not currently used on your board. – MarkU May 19 '16 at 5:52
  • Finally tracked down what Arduino Trinket is: ATtiny85 not ATmega328 - very different beast. Your linked example code uses SoftwareSerial (ATtiny85 has no hardware serial). Are you sure you have the correct flag settings? If the ATtiny85 was set to internal 1MHz clock instead of internal 8MHz clock, baud rate will be wrong. I'm not even sure if internal clock is stable enough to support serial comms. If the "trinket" has a external clock oscillator, make sure the ATtiny85 flags are correctly configured to use it. Try to wrangle an oscilloscope to verify the serial comms timing. – MarkU May 19 '16 at 6:08
0

Warning: I do not have a ATtiny85 nor the lcd so this is purely based on what I found after some reading up on this mcu.

What I would do in your situation: As the trinket is using a ATtiny85 it does not have hardware serial. So a software variant is needed.
You opted for software serial (which is the most obvous in Arduino world) but which seems to be the hardest solution. According to this source Serial communication with the Tiny's is is possible (And I quote)

you might have to tune the internal oscillator to get a stable connection.

Assuming your lcd does not need to send data back; I would try the TinyDebugSerial.

  • Bear in mind that adding an external crystal would be the easiest/most reliable. But this will cost you 2 specific I/O pins. There might also be memory issues, since the ATTiny85 has a lot less memory as the ATMega328. The Arduino Nano (or pro micro) might fit your physical size requirements, while being a lot more "powerfull". – Paul May 30 '16 at 6:14
0

Operating this display should not be out of the range of the ATTiny85 abilities. I have one using a two-way serial connection for a setup routine, that modifies EEPROM values.


First off connect to the LCD Backpack using the USB connector and test it through there to rule out it being faulty.

At the bottom of that page:

For more commands, check the github repository (see the Downloads tab) for a python script that will test all commands on the display.


Testing Trinket Serial:

What you can do is take your trinket and run a basic Serial connection program to test if the Trinket is sending the right info out.

Trinket:

#include <SoftwareSerial.h>
// Create a software serial port!
SoftwareSerial comm = SoftwareSerial(0, 1); //RX,TX
#define LEDPIN  PINB2
void setup() {
  //set baud
  comm.begin(9600);
  DDRB |= (1 << LEDPIN);  // set LED pin to output mode
}

void loop() {
  //print a specific character once a second

  comm.println('a');
  PORTB |= (1 << LEDPIN); // turn on LED
  delay(500);            // 0.5 second delay
  PORTB &= ~(1 << LEDPIN); // turn off LED
  delay(1000);
}

Then you need another Arduino, like an Uno, Leonardo:

// For leonardo use Serial1 for the connection to trinket 
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Ready...");

  // set the data rate for the SoftwareSerial port
  Serial1.begin(9600);
}

void loop() { // run over and over
  if (Serial1.available()) {
    char incoming = Serial.read();
    Serial.println(incoming);
  }

}

Or the stock balnk sketch and connect the Trinket Serial out to Arduino TX-> 1.

If using an UNO you can set up a SoftwareSerial style of the above.

I recommend this rather, a USB-Serial converter as it will be quicker and cleaner.

Next you need to see what is coming out. If the received data is correct then there is an issue in the LCD display, try re-flashing the LCD board with new firmware.

If the data comes through correctly then move onto using the Adafruit code and still connecting it to the other Arduino boards serial connection, replacing the Serial.println(Serial1.read()); with Serial.println(Serial1.read(),HEX);.

If the data still comes through correctly then the data is not being received properly by the LCD backpack.


LCD Backpack

You should test the display board with another Arduino, UNO or Leonardo (32u4).

Run the Adafruit tutorial code and see the results. If the code works then there is a problem with the Trinket and the SoftwareSerial library.

If there are again errors that happen with the LCD backpack when used with a 'normal' Arduino then it is the problem.


Recomendations

Download the ATTiny core from High-Low Tech and burn the 'bootloader' to reset the fuses to 8MHZ setting, also this is a good core to use if you want more space on the ATTiny.

Possibly re-flash the trinket bootloader and make sure the internal clock is 8MHz; the SoftwareSerial library is touchie I believe.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.