{"id":26871272,"url":"https://github.com/codeadamca/arduino-nodejs-lcd","last_synced_at":"2026-02-13T11:22:12.896Z","repository":{"id":115326640,"uuid":"302397592","full_name":"codeadamca/arduino-nodejs-lcd","owner":"codeadamca","description":"Communication between a browser interface and an LCD screen with an Arduino.","archived":false,"fork":false,"pushed_at":"2025-01-26T21:40:21.000Z","size":125,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T07:18:53.305Z","etag":null,"topics":["arduino","cplusplus","lcd","nodejs"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeadamca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-08T16:19:01.000Z","updated_at":"2025-01-26T21:40:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"a259302b-73a3-4aa3-8a05-24b027268d21","html_url":"https://github.com/codeadamca/arduino-nodejs-lcd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Farduino-nodejs-lcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Farduino-nodejs-lcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Farduino-nodejs-lcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Farduino-nodejs-lcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeadamca","download_url":"https://codeload.github.com/codeadamca/arduino-nodejs-lcd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252826496,"owners_count":21810121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","cplusplus","lcd","nodejs"],"created_at":"2025-03-31T07:18:57.419Z","updated_at":"2026-02-13T11:22:07.870Z","avatar_url":"https://github.com/codeadamca.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arduino, Node.js, and an LCD Screen\n\nThis tutorial will walkthrough the process of creating a web interface to display text on an Arduino connected LCD. The web interface will include a text box to type a message in.\n\n## HTML and JavaScript\n\nCreate an HTML file called `index.html`. Add the following code:\n\n```javascript\ntype html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n\n        \u003ctitle\u003eCommunicating from Node.js to an Arduino\u003c/title\u003e\n\n        \u003cscript src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js'\u003e\u003c/script\u003e\n\n    \u003c/head\u003e\n    \u003cbody\u003e\n\n        \u003ch1\u003eCommunicating from Node.js to an Arduino\u003c/h1\u003e\n\n        \u003cinput type=\"text\" name=\"message\" id=\"message\"\u003e\n\n        \u003cscript\u003e\n\n        var typingTimer;\n\n        document.getElementById('message').onkeyup = function() {\n\n            clearTimeout(typingTimer);\n            typingTimer = setTimeout(doneTyping, 1000);\n\n        };\n\n        var socket = io();\n\n        function doneTyping () {\n\n            socket.emit('newMessage', { \"message\":document.getElementById('message').value });\n            console.log(document.getElementById('message').value);\n\n        }\n\n        \u003c/script\u003e\n\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThe above code creates a webpage with a textbox. When text is entered the text is sent to the Node.js app using JavaScript and Socket.io.\n\n## Node.js Server\n\nCreate a file called `app.js` and add the following code:\n\n```javascript\nvar http = require(\"http\");\nvar fs = require(\"fs\");\nvar index = fs.readFileSync(\"index.html\");\n\nvar SerialPort = require(\"serialport\");\nconst parsers = SerialPort.parsers;\n\nconst parser = new parsers.Readline({\n  delimiter: \"\\r\\n\",\n});\n\nvar port = new SerialPort(\"/dev/tty.wchusbserialfa1410\", {\n  baudRate: 9600,\n  dataBits: 8,\n  parity: \"none\",\n  stopBits: 1,\n  flowControl: false,\n});\n\nport.pipe(parser);\n\nvar app = http.createServer(function (req, res) {\n  res.writeHead(200, {\"Content-Type\": \"text/html\"});\n  res.end(index);\n});\n\nvar io = require(\"socket.io\").listen(app);\n\nio.on(\"connection\", function (socket) {\n  socket.on(\"newMessage\", function (data) {\n    console.log(data);\n\n    port.write(data.message);\n  });\n});\n\nparser.on(\"data\", function (data) {\n  console.log(\"Received data from port: \" + data);\n});\n\napp.listen(3000);\n```\n\nThe above code uses Socket.io to listen for a message from the HTML/JavaScript webpage and then simply passes on the message to the connected Arduino.\n\n\u003e [!Note]  \n\u003e Make sure to [change the name of the serial port](https://github.com/codeadamca/arduino-from-nodejs).\n\n## The Arduino\n\nUsing [Arduino Create](https://create.arduino.cc/editor) create the following sketch and upload it to your Arduino.\n\n```csharp\n#include \u003cLiquidCrystal.h\u003e\n\nLiquidCrystal lcd(12, 11, 5, 4, 3, 2);\n\nvoid setup() {\n\n  lcd.begin(16, 2);\n  lcd.print(\"hello, world!\");\n\n  Serial.begin(9600);\n\n}\n\nvoid loop() {\n\n  if (Serial.available() \u003e 0) {\n\n    String receivedString = \"\";\n\n    while (Serial.available() \u003e 0) {\n      receivedString += char(Serial.read ());\n      delay(20);\n    }\n\n    Serial.println(receivedString);\n\n    lcd.clear();\n    lcd.setCursor(0, 0);\n    lcd.print(receivedString);\n\n  }\n\n  lcd.setCursor(0, 1);\n  lcd.print(millis() / 1000);\n\n}\n```\n\nThe previous code will listen to the serialport for an incoming message. Once a message is received it will display the message using the connected LCD.\n\n\u003e [View the Arduino code on Arduino Create](https://create.arduino.cc/editor/professoradam/cda3647d-a522-4b61-a6a7-e966f0492e94/preview)\n\nYou will need to setup the following circuit using your Arduino:\n\n![Tinkercad Circuit](_readme/tinkercad-nodejs-lcd.png)\n\n\u003e [View the Circuit on Tinkercad](https://www.tinkercad.com/things/9f5oKIl94XS)\n\n\u003e [Circuit copied from arduino.cc](https://create.arduino.cc/projecthub/zurrealStudios/lcd-backlight-and-contrast-control-6d3452)\n\n## Launch Application\n\n1. Using [Arduino Create](https://create.arduino.cc/editor) upload the sketch to your Arduino.\n2. Using the Terminal start your Node.js app using `node app.js`.\n3. Open up a browser and enter the URL `http://localhost:3000/`.\n4. Using your browser type in a message to display on your LCD screen.\n\n\u003e Full tutorial URL:  \n\u003e https://codeadam.ca/learning/arduino-from-nodejs.html\n\n---\n\n## Repo Resources\n\n- [Visual Studio Code](https://code.visualstudio.com/) or [Brackets](http://brackets.io/) (or any code editor)\n- [Arduino Create](https://create.arduino.cc/editor)\n- [SerialPort NPM](https://www.npmjs.com/package/serialport)\n- [Socket.io](https://socket.io/)\n\n\u003cbr\u003e\n\u003ca href=\"https://codeadam.ca\"\u003e\n\u003cimg src=\"https://cdn.codeadam.ca/images@1.0.0/codeadam-logo-coloured-horizontal.png\" width=\"200\"\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Farduino-nodejs-lcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeadamca%2Farduino-nodejs-lcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Farduino-nodejs-lcd/lists"}