From b54d1e26a3549b892d6983ab278150d002c8309a Mon Sep 17 00:00:00 2001 From: j4nk Date: Tue, 19 Dec 2023 03:29:26 -0500 Subject: [PATCH] Update 'README.md' --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb1e8ab..e64878c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ # arduino-lcd-writer -Driver code for arduino that enables writing to LCD from Linux \ No newline at end of file +Driver code for arduino that enables writing to LCD from Linux + +## Goal +Serial devices get assigned (at least on my machine) to /dev/ttyACM* (e.g. ACM0). My goal is to be able to write to `/dev/ttyACM0` and get the text displayed on the LCD display. +For example, a command like +`echo "Hello, world!" > /dev/ttyACM0` would result in "Hello, world!" being printed on the LCD. + +To this end, I wrote this program. It simply reads the serial port and prints the string to the screen, with one big idiosyncracy: since `\n` isn't handled by the `lcd.print()` function, I make `?` denote a newline. Hence, if the arduino reads something like +`Hello?World` on the serial bus, it will print "Hello" on the first line and "World" on the second. + +## Dependencies +This project depends on Arduino and [Arduino-Makefile](https://github.com/sudar/Arduino-Makefile). Unfortunately, my distro doesn't supply Arduino Makefile so I have to have the operation dependent on a bunch of environment variables. Many distros don't supply the Arduino libraries outside of the IDE so you probably have to install that. + +## Arduino configuration +I follow the exact wiring of the [official LCD tutorial](https://docs.arduino.cc/learn/electronics/lcd-displays). I have the 16 pin, 16x2 LCD screen used in that tutorial. If you have a different size, you can adjust the code. + +## Building +Download Arduino-Makefile and put it somewhere. Don't bother building or installing it unless you want to. +Simply clone this repository, open `Makefile`, and set the `ARDUINO_DIR`, `ARDMK_DIR`, and `AVR_TOOLS_DIR` to appropriate values. `ARDMK_DIR` should be wherever you downloaded Arduino-Makefile. e.g. on my setup, the three variables are set to `/usr/lib/arduino`, `~/.local/Arduino-Makefile`, and `/`, respectively. Then, + +Build the program with `make` + +Upload the program with `make upload` + +## Notes +Here I compile some notes on operation that would be a pain to search otherwise + +### How to run the program 100% successfully +By default, uploading this program and then writing to the serial device doesn't work for some reason. I follow these steps in this order to ensure correct operation. This assumes the program has already been uploaded to the Arduino. + +1. Run `make reset` in the program directory - this resets the serial interface +2. Run `tail -f /dev/ttyACM0 > /dev/null` - this creates a process that constantly listens on the serial connection, keeping it alive? I'm not sure but it doesn't work without this. +3. Write stuff to the serial device - now it should work + +### Previously was working +I basically had to rewrite this from scratch - the Arduino had the program uploaded on it but I lost the code. That version had fast refresh rates but this one takes like 2 seconds to refresh the LCD. I don't have any applications that would break due to this so it isn't important. +