├── .codespellrc ├── .github ├── dependabot.yml └── workflows │ ├── check-arduino.yml │ ├── compile-examples.yml │ ├── report-size-deltas.yml │ ├── spell-check.yml │ └── sync-labels.yml ├── LICENSE.txt ├── README.adoc ├── docs ├── api.md └── readme.md ├── examples ├── Autoscroll │ └── Autoscroll.ino ├── Blink │ └── Blink.ino ├── Cursor │ └── Cursor.ino ├── CustomCharacter │ └── CustomCharacter.ino ├── Display │ └── Display.ino ├── HelloWorld │ └── HelloWorld.ino ├── Scroll │ └── Scroll.ino ├── SerialDisplay │ └── SerialDisplay.ino ├── TextDirection │ └── TextDirection.ino └── setCursor │ └── setCursor.ino ├── keywords.txt ├── library.properties └── src ├── LiquidCrystal.cpp └── LiquidCrystal.h /.codespellrc: -------------------------------------------------------------------------------- 1 | # See: https://github.com/codespell-project/codespell#using-a-config-file 2 | [codespell] 3 | # In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: 4 | ignore-words-list = , 5 | check-filenames = 6 | check-hidden = 7 | skip = ./.git 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file 2 | version: 2 3 | 4 | updates: 5 | # Configure check for outdated GitHub Actions actions in workflows. 6 | # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot 7 | - package-ecosystem: github-actions 8 | directory: / # Check the repository's workflows under /.github/workflows/ 9 | schedule: 10 | interval: daily 11 | labels: 12 | - "topic: infrastructure" 13 | -------------------------------------------------------------------------------- /.github/workflows/check-arduino.yml: -------------------------------------------------------------------------------- 1 | name: Check Arduino 2 | 3 | # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows 4 | on: 5 | push: 6 | pull_request: 7 | schedule: 8 | # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. 9 | - cron: "0 8 * * TUE" 10 | workflow_dispatch: 11 | repository_dispatch: 12 | 13 | jobs: 14 | lint: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v4 20 | 21 | - name: Arduino Lint 22 | uses: arduino/arduino-lint-action@v2 23 | with: 24 | compliance: specification 25 | library-manager: update 26 | # Always use this setting for official repositories. Remove for 3rd party projects. 27 | official: true 28 | project-type: library 29 | -------------------------------------------------------------------------------- /.github/workflows/compile-examples.yml: -------------------------------------------------------------------------------- 1 | name: Compile Examples 2 | 3 | # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows 4 | on: 5 | push: 6 | paths: 7 | - ".github/workflows/compile-examples.yml" 8 | - "examples/**" 9 | - "src/**" 10 | pull_request: 11 | paths: 12 | - ".github/workflows/compile-examples.yml" 13 | - "examples/**" 14 | - "src/**" 15 | schedule: 16 | # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). 17 | - cron: "0 8 * * TUE" 18 | workflow_dispatch: 19 | repository_dispatch: 20 | 21 | jobs: 22 | build: 23 | name: ${{ matrix.board.fqbn }} 24 | runs-on: ubuntu-latest 25 | 26 | env: 27 | SKETCHES_REPORTS_PATH: sketches-reports 28 | 29 | strategy: 30 | fail-fast: false 31 | 32 | matrix: 33 | board: 34 | - fqbn: arduino:avr:nano 35 | platforms: | 36 | - name: arduino:avr 37 | artifact-name-suffix: arduino-avr-nano 38 | - fqbn: arduino:avr:mega 39 | platforms: | 40 | - name: arduino:avr 41 | artifact-name-suffix: arduino-avr-mega 42 | - fqbn: arduino:avr:leonardo 43 | platforms: | 44 | - name: arduino:avr 45 | artifact-name-suffix: arduino-avr-leonardo 46 | - fqbn: arduino:megaavr:nona4809 47 | platforms: | 48 | - name: arduino:megaavr 49 | artifact-name-suffix: arduino-megaavr-nona4809 50 | - fqbn: arduino:sam:arduino_due_x_dbg 51 | platforms: | 52 | - name: arduino:sam 53 | artifact-name-suffix: arduino-sam-arduino_due_x_dbg 54 | - fqbn: arduino:samd:mkrzero 55 | platforms: | 56 | - name: arduino:samd 57 | artifact-name-suffix: arduino-samd-mkrzero 58 | - fqbn: arduino:mbed_portenta:envie_m7:target_core=cm4 59 | platforms: | 60 | - name: arduino:mbed_portenta 61 | artifact-name-suffix: arduino-mbed_portenta-envie_m7-target_core-cm4 62 | - fqbn: arduino:mbed_portenta:envie_m7 63 | platforms: | 64 | - name: arduino:mbed_portenta 65 | artifact-name-suffix: arduino-mbed_portenta-envie_m7 66 | - fqbn: arduino:mbed_nano:nano33ble 67 | platforms: | 68 | - name: arduino:mbed_nano 69 | artifact-name-suffix: arduino-mbed_nano-nano33ble 70 | - fqbn: arduino:mbed_nano:nanorp2040connect 71 | platforms: | 72 | - name: arduino:mbed_nano 73 | artifact-name-suffix: arduino-mbed_nano-nanorp2040connect 74 | 75 | steps: 76 | - name: Checkout repository 77 | uses: actions/checkout@v4 78 | 79 | - name: Compile examples 80 | uses: arduino/compile-sketches@v1 81 | with: 82 | github-token: ${{ secrets.GITHUB_TOKEN }} 83 | fqbn: ${{ matrix.board.fqbn }} 84 | platforms: ${{ matrix.board.platforms }} 85 | libraries: | 86 | # Install the library from the local path. 87 | - source-path: ./ 88 | # Additional library dependencies can be listed here. 89 | # See: https://github.com/arduino/compile-sketches#libraries 90 | sketch-paths: | 91 | - examples 92 | enable-deltas-report: true 93 | sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} 94 | 95 | - name: Save sketches report as workflow artifact 96 | uses: actions/upload-artifact@v4 97 | with: 98 | if-no-files-found: error 99 | path: ${{ env.SKETCHES_REPORTS_PATH }} 100 | name: sketches-report-${{ matrix.board.artifact-name-suffix }} 101 | -------------------------------------------------------------------------------- /.github/workflows/report-size-deltas.yml: -------------------------------------------------------------------------------- 1 | name: Report Size Deltas 2 | 3 | # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows 4 | on: 5 | push: 6 | paths: 7 | - ".github/workflows/report-size-deltas.yml" 8 | schedule: 9 | # Run at the minimum interval allowed by GitHub Actions. 10 | # Note: GitHub Actions periodically has outages which result in workflow failures. 11 | # In this event, the workflows will start passing again once the service recovers. 12 | - cron: "*/5 * * * *" 13 | workflow_dispatch: 14 | repository_dispatch: 15 | 16 | jobs: 17 | report: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Comment size deltas reports to PRs 21 | uses: arduino/report-size-deltas@v1 22 | with: 23 | # Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow 24 | sketches-reports-source: ^sketches-report-.+ 25 | -------------------------------------------------------------------------------- /.github/workflows/spell-check.yml: -------------------------------------------------------------------------------- 1 | name: Spell Check 2 | 3 | # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows 4 | on: 5 | push: 6 | pull_request: 7 | schedule: 8 | # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. 9 | - cron: "0 8 * * TUE" 10 | workflow_dispatch: 11 | repository_dispatch: 12 | 13 | jobs: 14 | spellcheck: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v4 20 | 21 | - name: Spell check 22 | uses: codespell-project/actions-codespell@master 23 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md 2 | name: Sync Labels 3 | 4 | # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows 5 | on: 6 | push: 7 | paths: 8 | - ".github/workflows/sync-labels.ya?ml" 9 | - ".github/label-configuration-files/*.ya?ml" 10 | pull_request: 11 | paths: 12 | - ".github/workflows/sync-labels.ya?ml" 13 | - ".github/label-configuration-files/*.ya?ml" 14 | schedule: 15 | # Run daily at 8 AM UTC to sync with changes to shared label configurations. 16 | - cron: "0 8 * * *" 17 | workflow_dispatch: 18 | repository_dispatch: 19 | 20 | env: 21 | CONFIGURATIONS_FOLDER: .github/label-configuration-files 22 | CONFIGURATIONS_ARTIFACT: label-configuration-files 23 | 24 | jobs: 25 | check: 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - name: Checkout repository 30 | uses: actions/checkout@v4 31 | 32 | - name: Download JSON schema for labels configuration file 33 | id: download-schema 34 | uses: carlosperate/download-file-action@v2 35 | with: 36 | file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json 37 | location: ${{ runner.temp }}/label-configuration-schema 38 | 39 | - name: Install JSON schema validator 40 | run: | 41 | sudo npm install \ 42 | --global \ 43 | ajv-cli \ 44 | ajv-formats 45 | 46 | - name: Validate local labels configuration 47 | run: | 48 | # See: https://github.com/ajv-validator/ajv-cli#readme 49 | ajv validate \ 50 | --all-errors \ 51 | -c ajv-formats \ 52 | -s "${{ steps.download-schema.outputs.file-path }}" \ 53 | -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" 54 | 55 | download: 56 | needs: check 57 | runs-on: ubuntu-latest 58 | 59 | strategy: 60 | matrix: 61 | filename: 62 | # Filenames of the shared configurations to apply to the repository in addition to the local configuration. 63 | # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels 64 | - universal.yml 65 | 66 | steps: 67 | - name: Download 68 | uses: carlosperate/download-file-action@v2 69 | with: 70 | file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} 71 | 72 | - name: Pass configuration files to next job via workflow artifact 73 | uses: actions/upload-artifact@v4 74 | with: 75 | path: | 76 | *.yaml 77 | *.yml 78 | if-no-files-found: error 79 | name: ${{ env.CONFIGURATIONS_ARTIFACT }} 80 | 81 | sync: 82 | needs: download 83 | runs-on: ubuntu-latest 84 | 85 | steps: 86 | - name: Set environment variables 87 | run: | 88 | # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable 89 | echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" 90 | 91 | - name: Determine whether to dry run 92 | id: dry-run 93 | if: > 94 | github.event_name == 'pull_request' || 95 | ( 96 | ( 97 | github.event_name == 'push' || 98 | github.event_name == 'workflow_dispatch' 99 | ) && 100 | github.ref != format('refs/heads/{0}', github.event.repository.default_branch) 101 | ) 102 | run: | 103 | # Use of this flag in the github-label-sync command will cause it to only check the validity of the 104 | # configuration. 105 | echo "::set-output name=flag::--dry-run" 106 | 107 | - name: Checkout repository 108 | uses: actions/checkout@v4 109 | 110 | - name: Download configuration files artifact 111 | uses: actions/download-artifact@v4 112 | with: 113 | name: ${{ env.CONFIGURATIONS_ARTIFACT }} 114 | path: ${{ env.CONFIGURATIONS_FOLDER }} 115 | 116 | - name: Remove unneeded artifact 117 | uses: geekyeggo/delete-artifact@v5 118 | with: 119 | name: ${{ env.CONFIGURATIONS_ARTIFACT }} 120 | 121 | - name: Merge label configuration files 122 | run: | 123 | # Merge all configuration files 124 | shopt -s extglob 125 | cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" 126 | 127 | - name: Install github-label-sync 128 | run: sudo npm install --global github-label-sync 129 | 130 | - name: Sync labels 131 | env: 132 | GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} 133 | run: | 134 | # See: https://github.com/Financial-Times/github-label-sync 135 | github-label-sync \ 136 | --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ 137 | ${{ steps.dry-run.outputs.flag }} \ 138 | ${{ github.repository }} 139 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | , 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | :repository-owner: arduino-libraries 2 | :repository-name: LiquidCrystal 3 | 4 | = {repository-name} Library for Arduino = 5 | 6 | image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml/badge.svg["Check Arduino status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml"] 7 | image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml/badge.svg["Compile Examples status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml"] 8 | image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml/badge.svg["Spell Check status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml"] 9 | 10 | This library allows an Arduino board to control liquid crystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. 11 | 12 | For more information about this library please visit us at 13 | 14 | https://www.arduino.cc/en/Reference/{repository-name} 15 | 16 | == License == 17 | 18 | Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. 19 | Copyright (c) 2010 Arduino LLC. All rights reserved. 20 | 21 | This library is free software; you can redistribute it and/or 22 | modify it under the terms of the GNU Lesser General Public 23 | License as published by the Free Software Foundation; either 24 | version 2.1 of the License, or (at your option) any later version. 25 | 26 | This library is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with this library; if not, write to the Free Software 33 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 34 | -------------------------------------------------------------------------------- /docs/api.md: -------------------------------------------------------------------------------- 1 | # LiquidCrystal 2 | 3 | ## Functions 4 | 5 | ### `LiquidCrystal()` 6 | 7 | #### Description 8 | 9 | Creates a variable of type LiquidCrystal. The display can be controlled using 4 or 8 data lines. If the former, omit the pin numbers for d0 to d3 and leave those lines unconnected. The RW pin can be tied to ground instead of connected to a pin on the Arduino; if so, omit it from this function's parameters. 10 | 11 | #### Syntax 12 | 13 | ``` 14 | LiquidCrystal(rs, enable, d4, d5, d6, d7) 15 | LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) 16 | LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7) 17 | LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7) 18 | ``` 19 | 20 | #### Parameters 21 | rs: the number of the Arduino pin that is connected to the RS pin on the LCD 22 | 23 | rw: the number of the Arduino pin that is connected to the RW pin on the LCD (optional) 24 | 25 | enable: the number of the Arduino pin that is connected to the enable pin on the LCD 26 | 27 | d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7). 28 | 29 | #### Example 30 | 31 | ``` 32 | #include 33 | 34 | LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); 35 | 36 | void setup() 37 | { 38 | lcd.begin(16,1); 39 | lcd.print("hello, world!"); 40 | } 41 | 42 | void loop() {} 43 | ``` 44 | 45 | ### `begin()` 46 | 47 | #### Description 48 | 49 | Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display. begin() needs to be called before any other LCD library commands. 50 | 51 | #### Syntax 52 | 53 | ``` 54 | lcd.begin(cols, rows, charsize) 55 | ``` 56 | 57 | #### Parameters 58 | lcd: a variable of type LiquidCrystal 59 | 60 | cols: the number of columns that the display has 61 | 62 | rows: the number of rows that the display has 63 | 64 | charsize (optional): the number of dots the display has per character: LCD_5x8DOTS for 5x8, LCD_5x10DOTS for 5x10. (default: LCD_5x8DOTS) 65 | 66 | ### `clear()` 67 | 68 | #### Description 69 | 70 | Clears the LCD screen and positions the cursor in the upper-left corner. 71 | 72 | #### Syntax 73 | 74 | ``` 75 | lcd.clear() 76 | ``` 77 | 78 | #### Parameters 79 | lcd: a variable of type LiquidCrystal 80 | 81 | ### `home()` 82 | 83 | #### Description 84 | 85 | Positions the cursor in the upper-left of the LCD. That is, use that location in outputting subsequent text to the display. To also clear the display, use the clear() function instead. 86 | 87 | #### Syntax 88 | 89 | ``` 90 | lcd.home() 91 | ``` 92 | 93 | #### Parameters 94 | lcd: a variable of type LiquidCrystal 95 | 96 | 97 | ### `setCursor()` 98 | 99 | #### Description 100 | 101 | Position the LCD cursor; that is, set the location at which subsequent text written to the LCD will be displayed. 102 | 103 | #### Syntax 104 | 105 | ``` 106 | lcd.setCursor(col, row) 107 | ``` 108 | 109 | #### Parameters 110 | lcd: a variable of type LiquidCrystal 111 | 112 | col: the column at which to position the cursor (with 0 being the first column) 113 | 114 | row: the row at which to position the cursor (with 0 being the first row) 115 | 116 | ### `write()` 117 | 118 | #### Description 119 | 120 | Write a character to the LCD. 121 | 122 | #### Syntax 123 | 124 | ``` 125 | lcd.write(data) 126 | ``` 127 | 128 | #### Parameters 129 | lcd: a variable of type LiquidCrystal 130 | 131 | data: the character to write to the display 132 | 133 | #### Returns 134 | 135 | byte 136 | write() will return the number of bytes written, though reading that number is optional 137 | 138 | #### Example 139 | 140 | ``` 141 | #include 142 | 143 | LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); 144 | 145 | void setup() 146 | { 147 | Serial.begin(9600); 148 | } 149 | 150 | void loop() 151 | { 152 | if (Serial.available()) { 153 | lcd.write(Serial.read()); 154 | } 155 | } 156 | ``` 157 | 158 | ### `print()` 159 | 160 | #### Description 161 | 162 | Prints text to the LCD. 163 | 164 | #### Syntax 165 | 166 | ``` 167 | lcd.print(data) 168 | lcd.print(data, BASE) 169 | ``` 170 | 171 | #### Parameters 172 | lcd: a variable of type LiquidCrystal 173 | 174 | data: the data to print (char, byte, int, long, or string) 175 | 176 | BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16). 177 | 178 | #### Returns 179 | 180 | byte 181 | print() will return the number of bytes written, though reading that number is optional 182 | 183 | #### Example 184 | 185 | ``` 186 | #include 187 | 188 | LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); 189 | 190 | void setup() 191 | { 192 | lcd.print("hello, world!"); 193 | } 194 | 195 | void loop() {} 196 | ``` 197 | 198 | ### `cursor()` 199 | 200 | #### Description 201 | 202 | Display the LCD cursor: an underscore (line) at the position to which the next character will be written. 203 | 204 | #### Syntax 205 | 206 | ``` 207 | lcd.cursor() 208 | ``` 209 | 210 | #### Parameters 211 | lcd: a variable of type LiquidCrystal 212 | 213 | 214 | ### `noCursor()` 215 | 216 | #### Description 217 | 218 | Hides the LCD cursor. 219 | 220 | #### Syntax 221 | 222 | ``` 223 | lcd.noCursor() 224 | ``` 225 | 226 | #### Parameters 227 | lcd: a variable of type LiquidCrystal 228 | 229 | 230 | ### `blink()` 231 | 232 | #### Description 233 | 234 | Display the blinking LCD cursor. If used in combination with the cursor() function, the result will depend on the particular display. 235 | 236 | #### Syntax 237 | 238 | ``` 239 | lcd.blink() 240 | ``` 241 | 242 | #### Parameters 243 | lcd: a variable of type LiquidCrystal 244 | 245 | ### `noBlink()` 246 | 247 | #### Description 248 | 249 | Turns off the blinking LCD cursor. 250 | 251 | #### Syntax 252 | 253 | ``` 254 | lcd.noBlink() 255 | ``` 256 | 257 | #### Parameters 258 | lcd: a variable of type LiquidCrystal 259 | 260 | ### `display()` 261 | 262 | #### Description 263 | 264 | Turns on the LCD display, after it's been turned off with noDisplay(). This will restore the text (and cursor) that was on the display. 265 | 266 | #### Syntax 267 | 268 | ``` 269 | lcd.display() 270 | ``` 271 | 272 | #### Parameters 273 | lcd: a variable of type LiquidCrystal 274 | 275 | ### `noDisplay()` 276 | 277 | #### Description 278 | 279 | Turns off the LCD display, without losing the text currently shown on it. 280 | 281 | #### Syntax 282 | 283 | ``` 284 | lcd.noDisplay() 285 | ``` 286 | 287 | #### Parameters 288 | lcd: a variable of type LiquidCrystal 289 | 290 | ### `scrollDisplayLeft()` 291 | 292 | #### Description 293 | 294 | Scrolls the contents of the display (text and cursor) one space to the left. 295 | 296 | #### Syntax 297 | 298 | ``` 299 | lcd.scrollDisplayLeft() 300 | ``` 301 | 302 | #### Parameters 303 | lcd: a variable of type LiquidCrystal 304 | 305 | ### `scrollDisplayRight()` 306 | 307 | #### Description 308 | 309 | Scrolls the contents of the display (text and cursor) one space to the right. 310 | 311 | #### Syntax 312 | 313 | ``` 314 | lcd.scrollDisplayRight() 315 | ``` 316 | 317 | #### Parameters 318 | lcd: a variable of type LiquidCrystal 319 | 320 | ### `autoscroll()` 321 | 322 | #### Description 323 | 324 | Turns on automatic scrolling of the LCD. This causes each character output to the display to push previous characters over by one space. If the current text direction is left-to-right (the default), the display scrolls to the left; if the current direction is right-to-left, the display scrolls to the right. This has the effect of outputting each new character to the same location on the LCD. 325 | 326 | #### Syntax 327 | 328 | ``` 329 | lcd.autoscroll() 330 | ``` 331 | 332 | #### Parameters 333 | lcd: a variable of type LiquidCrystal 334 | 335 | ### `noAutoscroll()` 336 | 337 | #### Description 338 | 339 | Turns off automatic scrolling of the LCD. 340 | 341 | #### Syntax 342 | 343 | ``` 344 | lcd.noAutoscroll() 345 | ``` 346 | 347 | #### Parameters 348 | lcd: a variable of type LiquidCrystal 349 | 350 | ### `leftToRight()` 351 | 352 | #### Description 353 | 354 | Set the direction for text written to the LCD to left-to-right, the default. This means that subsequent characters written to the display will go from left to right, but does not affect previously-output text. 355 | 356 | #### Syntax 357 | 358 | ``` 359 | lcd.leftToRight() 360 | ``` 361 | 362 | #### Parameters 363 | lcd: a variable of type LiquidCrystal 364 | 365 | ### `rightToLeft()` 366 | 367 | #### Description 368 | 369 | Set the direction for text written to the LCD to right-to-left (the default is left-to-right). This means that subsequent characters written to the display will go from right to left, but does not affect previously-output text. 370 | 371 | #### Syntax 372 | 373 | ``` 374 | lcd.rightToLeft() 375 | ``` 376 | 377 | #### Parameters 378 | lcd: a variable of type LiquidCrystal 379 | 380 | ### `createChar()` 381 | 382 | #### Description 383 | 384 | Create a custom character (glyph) for use on the LCD. Up to eight characters of 5x8 pixels are supported (numbered 0 to 7). The appearance of each custom character is specified by an array of eight bytes, one for each row. The five least significant bits of each byte determine the pixels in that row. To display a custom character on the screen, write() its number. 385 | 386 | >NB : When referencing custom character "0", if it is not in a variable, you need to cast it as a byte, otherwise the compiler throws an error. 387 | 388 | #### Syntax 389 | 390 | ``` 391 | lcd.createChar(num, data) 392 | ``` 393 | 394 | #### Parameters 395 | lcd: a variable of type LiquidCrystal 396 | 397 | num: which character to create (0 to 7) 398 | 399 | data: the character's pixel data 400 | 401 | #### Example 402 | 403 | ``` 404 | 405 | #include 406 | 407 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 408 | 409 | byte smiley[8] = { 410 | B00000, 411 | B10001, 412 | B00000, 413 | B00000, 414 | B10001, 415 | B01110, 416 | B00000, 417 | }; 418 | 419 | void setup() { 420 | lcd.createChar(0, smiley); 421 | lcd.begin(16, 2); 422 | lcd.write(byte(0)); 423 | } 424 | 425 | void loop() {} 426 | ``` 427 | -------------------------------------------------------------------------------- /docs/readme.md: -------------------------------------------------------------------------------- 1 | # LiquidCrystal 2 | 3 | This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). 4 | 5 | To use this library: 6 | 7 | ``` 8 | #include 9 | ``` -------------------------------------------------------------------------------- /examples/Autoscroll/Autoscroll.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Autoscroll 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch demonstrates the use of the autoscroll() 10 | and noAutoscroll() functions to make new text scroll or not. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K or 100K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | 24 | Library originally added 18 Apr 2008 25 | by David A. Mellis 26 | library modified 5 Jul 2009 27 | by Limor Fried (http://www.ladyada.net) 28 | example added 9 Jul 2009 29 | by Tom Igoe 30 | modified 22 Nov 2010 31 | by Tom Igoe 32 | modified 7 Nov 2016 33 | by Arturo Guadalupi 34 | 35 | This example code is in the public domain. 36 | 37 | https://docs.arduino.cc/learn/electronics/lcd-displays#autoscroll-example 38 | https://github.com/arduino-libraries/LiquidCrystal 39 | */ 40 | 41 | // include the library code: 42 | #include 43 | 44 | // initialize the library by associating any needed LCD interface pin 45 | // with the Arduino pin number it is connected to 46 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 47 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 48 | 49 | void setup() { 50 | // set up the LCD's number of columns and rows: 51 | lcd.begin(16, 2); 52 | } 53 | 54 | void loop() { 55 | // set the cursor to (0,0): 56 | lcd.setCursor(0, 0); 57 | // print from 0 to 9: 58 | for (int thisChar = 0; thisChar < 10; thisChar++) { 59 | lcd.print(thisChar); 60 | delay(500); 61 | } 62 | 63 | // set the cursor to (16,1): 64 | lcd.setCursor(16, 1); 65 | // set the display to automatically scroll: 66 | lcd.autoscroll(); 67 | // print from 0 to 9: 68 | for (int thisChar = 0; thisChar < 10; thisChar++) { 69 | lcd.print(thisChar); 70 | delay(500); 71 | } 72 | // turn off automatic scrolling 73 | lcd.noAutoscroll(); 74 | 75 | // clear screen for the next loop: 76 | lcd.clear(); 77 | } 78 | -------------------------------------------------------------------------------- /examples/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Blink 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "hello, world!" to the LCD and makes the 10 | cursor block blink. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K or 100K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | 24 | Library originally added 18 Apr 2008 25 | by David A. Mellis 26 | library modified 5 Jul 2009 27 | by Limor Fried (http://www.ladyada.net) 28 | example added 9 Jul 2009 29 | by Tom Igoe 30 | modified 22 Nov 2010 31 | by Tom Igoe 32 | modified 7 Nov 2016 33 | by Arturo Guadalupi 34 | 35 | This example code is in the public domain. 36 | 37 | https://docs.arduino.cc/learn/electronics/lcd-displays#blink-example 38 | https://github.com/arduino-libraries/LiquidCrystal 39 | 40 | */ 41 | 42 | // include the library code: 43 | #include 44 | 45 | // initialize the library by associating any needed LCD interface pin 46 | // with the Arduino pin number it is connected to 47 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 48 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 49 | 50 | void setup() { 51 | // set up the LCD's number of columns and rows: 52 | lcd.begin(16, 2); 53 | // Print a message to the LCD. 54 | lcd.print("hello, world!"); 55 | } 56 | 57 | void loop() { 58 | // Turn off the blinking cursor: 59 | lcd.noBlink(); 60 | delay(3000); 61 | // Turn on the blinking cursor: 62 | lcd.blink(); 63 | delay(3000); 64 | } 65 | -------------------------------------------------------------------------------- /examples/Cursor/Cursor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Cursor 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "hello, world!" to the LCD and 10 | uses the cursor() and noCursor() methods to turn 11 | on and off the cursor. 12 | 13 | The circuit: 14 | * LCD RS pin to digital pin 12 15 | * LCD Enable pin to digital pin 11 16 | * LCD D4 pin to digital pin 5 17 | * LCD D5 pin to digital pin 4 18 | * LCD D6 pin to digital pin 3 19 | * LCD D7 pin to digital pin 2 20 | * LCD R/W pin to ground 21 | * 10K or 100K potentiometer: 22 | * ends to +5V and ground 23 | * wiper to LCD VO pin (pin 3) 24 | 25 | Library originally added 18 Apr 2008 26 | by David A. Mellis 27 | library modified 5 Jul 2009 28 | by Limor Fried (http://www.ladyada.net) 29 | example added 9 Jul 2009 30 | by Tom Igoe 31 | modified 22 Nov 2010 32 | by Tom Igoe 33 | modified 7 Nov 2016 34 | by Arturo Guadalupi 35 | 36 | This example code is in the public domain. 37 | 38 | https://docs.arduino.cc/learn/electronics/lcd-displays#cursor 39 | https://github.com/arduino-libraries/LiquidCrystal 40 | */ 41 | 42 | // include the library code: 43 | #include 44 | 45 | // initialize the library by associating any needed LCD interface pin 46 | // with the Arduino pin number it is connected to 47 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 48 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 49 | 50 | void setup() { 51 | // set up the LCD's number of columns and rows: 52 | lcd.begin(16, 2); 53 | // Print a message to the LCD. 54 | lcd.print("hello, world!"); 55 | } 56 | 57 | void loop() { 58 | // Turn off the cursor: 59 | lcd.noCursor(); 60 | delay(500); 61 | // Turn on the cursor: 62 | lcd.cursor(); 63 | delay(500); 64 | } 65 | -------------------------------------------------------------------------------- /examples/CustomCharacter/CustomCharacter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Custom Characters 3 | 4 | Demonstrates how to add custom characters on an LCD display. 5 | The LiquidCrystal library works with all LCD displays that are 6 | compatible with the Hitachi HD44780 driver. There are many of 7 | them out there, and you can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "I Arduino!" and a little dancing man 10 | to the LCD. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | * 10K potentiometer on pin A0 24 | 25 | created 21 Mar 2011 26 | by Tom Igoe 27 | modified 11 Nov 2013 28 | by Scott Fitzgerald 29 | modified 7 Nov 2016 30 | by Arturo Guadalupi 31 | modified 17 Mar 2020 32 | by Deepak Khatri 33 | 34 | Based on Adafruit's example at 35 | https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde 36 | 37 | This example code is in the public domain. 38 | 39 | https://docs.arduino.cc/learn/electronics/lcd-displays#custom-character 40 | https://github.com/arduino-libraries/LiquidCrystal 41 | 42 | 43 | Also useful: 44 | https://maxpromer.github.io/LCD-Character-Creator/ 45 | 46 | */ 47 | 48 | // include the library code: 49 | #include 50 | 51 | // initialize the library by associating any needed LCD interface pin 52 | // with the Arduino pin number it is connected to 53 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 54 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 55 | 56 | // make some custom characters: 57 | byte heart[8] = { 58 | 0b00000, 59 | 0b01010, 60 | 0b11111, 61 | 0b11111, 62 | 0b11111, 63 | 0b01110, 64 | 0b00100, 65 | 0b00000 66 | }; 67 | 68 | byte smiley[8] = { 69 | 0b00000, 70 | 0b00000, 71 | 0b01010, 72 | 0b00000, 73 | 0b00000, 74 | 0b10001, 75 | 0b01110, 76 | 0b00000 77 | }; 78 | 79 | byte frownie[8] = { 80 | 0b00000, 81 | 0b00000, 82 | 0b01010, 83 | 0b00000, 84 | 0b00000, 85 | 0b00000, 86 | 0b01110, 87 | 0b10001 88 | }; 89 | 90 | byte armsDown[8] = { 91 | 0b00100, 92 | 0b01010, 93 | 0b00100, 94 | 0b00100, 95 | 0b01110, 96 | 0b10101, 97 | 0b00100, 98 | 0b01010 99 | }; 100 | 101 | byte armsUp[8] = { 102 | 0b00100, 103 | 0b01010, 104 | 0b00100, 105 | 0b10101, 106 | 0b01110, 107 | 0b00100, 108 | 0b00100, 109 | 0b01010 110 | }; 111 | 112 | void setup() { 113 | // initialize LCD and set up the number of columns and rows: 114 | lcd.begin(16, 2); 115 | 116 | // create a new character 117 | lcd.createChar(0, heart); 118 | // create a new character 119 | lcd.createChar(1, smiley); 120 | // create a new character 121 | lcd.createChar(2, frownie); 122 | // create a new character 123 | lcd.createChar(3, armsDown); 124 | // create a new character 125 | lcd.createChar(4, armsUp); 126 | 127 | // set the cursor to the top left 128 | lcd.setCursor(0, 0); 129 | 130 | // Print a message to the LCD. 131 | lcd.print("I "); 132 | lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte 133 | lcd.print(" Arduino! "); 134 | lcd.write((byte)1); 135 | 136 | } 137 | 138 | void loop() { 139 | // read the potentiometer on A0: 140 | int sensorReading = analogRead(A0); 141 | // map the result to 200 - 1000: 142 | int delayTime = map(sensorReading, 0, 1023, 200, 1000); 143 | // set the cursor to the bottom row, 5th position: 144 | lcd.setCursor(4, 1); 145 | // draw the little man, arms down: 146 | lcd.write(3); 147 | delay(delayTime); 148 | lcd.setCursor(4, 1); 149 | // draw him arms up: 150 | lcd.write(4); 151 | delay(delayTime); 152 | } 153 | -------------------------------------------------------------------------------- /examples/Display/Display.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - display() and noDisplay() 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "hello, world!" to the LCD and uses the 10 | display() and noDisplay() functions to turn on and off 11 | the display. 12 | 13 | The circuit: 14 | * LCD RS pin to digital pin 12 15 | * LCD Enable pin to digital pin 11 16 | * LCD D4 pin to digital pin 5 17 | * LCD D5 pin to digital pin 4 18 | * LCD D6 pin to digital pin 3 19 | * LCD D7 pin to digital pin 2 20 | * LCD R/W pin to ground 21 | * 10K or 100K potentiometer: 22 | * ends to +5V and ground 23 | * wiper to LCD VO pin (pin 3) 24 | 25 | Library originally added 18 Apr 2008 26 | by David A. Mellis 27 | library modified 5 Jul 2009 28 | by Limor Fried (http://www.ladyada.net) 29 | example added 9 Jul 2009 30 | by Tom Igoe 31 | modified 22 Nov 2010 32 | by Tom Igoe 33 | modified 7 Nov 2016 34 | by Arturo Guadalupi 35 | 36 | This example code is in the public domain. 37 | 38 | https://docs.arduino.cc/learn/electronics/lcd-displays#display-example 39 | https://github.com/arduino-libraries/LiquidCrystal 40 | 41 | */ 42 | 43 | // include the library code: 44 | #include 45 | 46 | // initialize the library by associating any needed LCD interface pin 47 | // with the Arduino pin number it is connected to 48 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 49 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 50 | 51 | void setup() { 52 | // set up the LCD's number of columns and rows: 53 | lcd.begin(16, 2); 54 | // Print a message to the LCD. 55 | lcd.print("hello, world!"); 56 | } 57 | 58 | void loop() { 59 | // Turn off the display: 60 | lcd.noDisplay(); 61 | delay(500); 62 | // Turn on the display: 63 | lcd.display(); 64 | delay(500); 65 | } 66 | -------------------------------------------------------------------------------- /examples/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Hello World 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "hello, world!" to the LCD 10 | and shows the time. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K or 100K potentiometer: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | 26 | Library originally added 18 Apr 2008 27 | by David A. Mellis 28 | library modified 5 Jul 2009 29 | by Limor Fried (http://www.ladyada.net) 30 | example added 9 Jul 2009 31 | by Tom Igoe 32 | modified 22 Nov 2010 33 | by Tom Igoe 34 | modified 7 Nov 2016 35 | by Arturo Guadalupi 36 | 37 | This example code is in the public domain. 38 | 39 | See https://docs.arduino.cc/learn/electronics/lcd-displays#hello-world-example 40 | 41 | Code maintained at https://github.com/arduino-libraries/LiquidCrystal 42 | 43 | */ 44 | 45 | // include the library code: 46 | #include 47 | 48 | // initialize the library by associating any needed LCD interface pin 49 | // with the Arduino pin number it is connected to 50 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 51 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 52 | 53 | void setup() { 54 | // set up the LCD's number of columns and rows: 55 | lcd.begin(16, 2); 56 | // Print a message to the LCD. 57 | lcd.print("hello, world!"); 58 | } 59 | 60 | void loop() { 61 | // set the cursor to column 0, line 1 62 | // (note: line 1 is the second row, since counting begins with 0): 63 | lcd.setCursor(0, 1); 64 | // print the number of seconds since reset: 65 | lcd.print(millis() / 1000); 66 | } 67 | -------------------------------------------------------------------------------- /examples/Scroll/Scroll.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "hello, world!" to the LCD and uses the 10 | scrollDisplayLeft() and scrollDisplayRight() methods to scroll 11 | the text. 12 | 13 | The circuit: 14 | * LCD RS pin to digital pin 12 15 | * LCD Enable pin to digital pin 11 16 | * LCD D4 pin to digital pin 5 17 | * LCD D5 pin to digital pin 4 18 | * LCD D6 pin to digital pin 3 19 | * LCD D7 pin to digital pin 2 20 | * LCD R/W pin to ground 21 | * 10K or 100K potentiometer: 22 | * ends to +5V and ground 23 | * wiper to LCD VO pin (pin 3) 24 | 25 | Library originally added 18 Apr 2008 26 | by David A. Mellis 27 | library modified 5 Jul 2009 28 | by Limor Fried (http://www.ladyada.net) 29 | example added 9 Jul 2009 30 | by Tom Igoe 31 | modified 22 Nov 2010 32 | by Tom Igoe 33 | modified 7 Nov 2016 34 | by Arturo Guadalupi 35 | 36 | This example code is in the public domain. 37 | 38 | https://docs.arduino.cc/learn/electronics/lcd-displays#scroll-example 39 | https://github.com/arduino-libraries/LiquidCrystal 40 | 41 | */ 42 | 43 | // include the library code: 44 | #include 45 | 46 | // initialize the library by associating any needed LCD interface pin 47 | // with the Arduino pin number it is connected to 48 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 49 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 50 | 51 | void setup() { 52 | // set up the LCD's number of columns and rows: 53 | lcd.begin(16, 2); 54 | // Print a message to the LCD. 55 | lcd.print("hello, world!"); 56 | delay(1000); 57 | } 58 | 59 | void loop() { 60 | // scroll 13 positions (string length) to the left 61 | // to move it offscreen left: 62 | for (int positionCounter = 0; positionCounter < 13; positionCounter++) { 63 | // scroll one position left: 64 | lcd.scrollDisplayLeft(); 65 | // wait a bit: 66 | delay(150); 67 | } 68 | 69 | // scroll 29 positions (string length + display length) to the right 70 | // to move it offscreen right: 71 | for (int positionCounter = 0; positionCounter < 29; positionCounter++) { 72 | // scroll one position right: 73 | lcd.scrollDisplayRight(); 74 | // wait a bit: 75 | delay(150); 76 | } 77 | 78 | // scroll 16 positions (display length + string length) to the left 79 | // to move it back to center: 80 | for (int positionCounter = 0; positionCounter < 16; positionCounter++) { 81 | // scroll one position left: 82 | lcd.scrollDisplayLeft(); 83 | // wait a bit: 84 | delay(150); 85 | } 86 | 87 | // delay at the end of the full loop: 88 | delay(1000); 89 | } 90 | -------------------------------------------------------------------------------- /examples/SerialDisplay/SerialDisplay.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Serial Input 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch displays text sent over the serial port 10 | (e.g. from the Serial Monitor) on an attached LCD. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K or 100K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | 24 | Library originally added 18 Apr 2008 25 | by David A. Mellis 26 | library modified 5 Jul 2009 27 | by Limor Fried (http://www.ladyada.net) 28 | example added 9 Jul 2009 29 | by Tom Igoe 30 | modified 22 Nov 2010 31 | by Tom Igoe 32 | modified 7 Nov 2016 33 | by Arturo Guadalupi 34 | 35 | This example code is in the public domain. 36 | 37 | https://docs.arduino.cc/learn/electronics/lcd-displays#serial-to-display-example 38 | https://github.com/arduino-libraries/LiquidCrystal 39 | 40 | */ 41 | 42 | // include the library code: 43 | #include 44 | 45 | // initialize the library by associating any needed LCD interface pin 46 | // with the Arduino pin number it is connected to 47 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 48 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 49 | 50 | void setup() { 51 | // set up the LCD's number of columns and rows: 52 | lcd.begin(16, 2); 53 | // initialize the serial communications: 54 | Serial.begin(9600); 55 | } 56 | 57 | void loop() { 58 | // when characters arrive over the serial port... 59 | if (Serial.available()) { 60 | // wait a bit for the entire message to arrive 61 | delay(100); 62 | // clear the screen 63 | lcd.clear(); 64 | // read all the available characters 65 | while (Serial.available() > 0) { 66 | // display each character to the LCD 67 | lcd.write(Serial.read()); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /examples/TextDirection/TextDirection.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - TextDirection 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch demonstrates how to use leftToRight() and rightToLeft() 10 | to move the cursor. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K or 100K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | 24 | Library originally added 18 Apr 2008 25 | by David A. Mellis 26 | library modified 5 Jul 2009 27 | by Limor Fried (http://www.ladyada.net) 28 | example added 9 Jul 2009 29 | by Tom Igoe 30 | modified 22 Nov 2010 31 | by Tom Igoe 32 | modified 7 Nov 2016 33 | by Arturo Guadalupi 34 | 35 | This example code is in the public domain. 36 | 37 | https://docs.arduino.cc/learn/electronics/lcd-displays#text-direction-example 38 | https://github.com/arduino-libraries/LiquidCrystal 39 | 40 | */ 41 | 42 | // include the library code: 43 | #include 44 | 45 | // initialize the library by associating any needed LCD interface pin 46 | // with the Arduino pin number it is connected to 47 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 48 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 49 | 50 | int thisChar = 'a'; 51 | 52 | void setup() { 53 | // set up the LCD's number of columns and rows: 54 | lcd.begin(16, 2); 55 | // turn on the cursor: 56 | lcd.cursor(); 57 | } 58 | 59 | void loop() { 60 | // reverse directions at 'm': 61 | if (thisChar == 'm') { 62 | // go right for the next letter 63 | lcd.rightToLeft(); 64 | } 65 | // reverse again at 's': 66 | if (thisChar == 's') { 67 | // go left for the next letter 68 | lcd.leftToRight(); 69 | } 70 | // reset at 'z': 71 | if (thisChar > 'z') { 72 | // go to (0,0): 73 | lcd.home(); 74 | // start again at 0 75 | thisChar = 'a'; 76 | } 77 | // print the character 78 | lcd.write(thisChar); 79 | // wait a second: 80 | delay(1000); 81 | // increment the letter: 82 | thisChar++; 83 | } 84 | -------------------------------------------------------------------------------- /examples/setCursor/setCursor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - setCursor 3 | 4 | Demonstrates the use of a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints to all the positions of the LCD using the 10 | setCursor() method: 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K or 100K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | 24 | Library originally added 18 Apr 2008 25 | by David A. Mellis 26 | library modified 5 Jul 2009 27 | by Limor Fried (http://www.ladyada.net) 28 | example added 9 Jul 2009 29 | by Tom Igoe 30 | modified 22 Nov 2010 31 | by Tom Igoe 32 | modified 7 Nov 2016 33 | by Arturo Guadalupi 34 | 35 | This example code is in the public domain. 36 | 37 | https://docs.arduino.cc/learn/electronics/lcd-displays#cursor 38 | https://github.com/arduino-libraries/LiquidCrystal 39 | 40 | */ 41 | 42 | // include the library code: 43 | #include 44 | 45 | // initialize the library by associating any needed LCD interface pin 46 | // with the Arduino pin number it is connected to 47 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 48 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 49 | 50 | // these constants won't change. But you can change the size of 51 | // your LCD using them: 52 | const int numRows = 2; 53 | const int numCols = 16; 54 | 55 | void setup() { 56 | // set up the LCD's number of columns and rows: 57 | lcd.begin(numCols, numRows); 58 | } 59 | 60 | void loop() { 61 | // loop from ASCII 'a' to ASCII 'z': 62 | for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { 63 | // loop over the columns: 64 | for (int thisRow = 0; thisRow < numRows; thisRow++) { 65 | // loop over the rows: 66 | for (int thisCol = 0; thisCol < numCols; thisCol++) { 67 | // set the cursor position: 68 | lcd.setCursor(thisCol, thisRow); 69 | // print the letter: 70 | lcd.write(thisLetter); 71 | delay(200); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LiquidCrystal 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | LiquidCrystal KEYWORD1 LiquidCrystal 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | clear KEYWORD2 17 | home KEYWORD2 18 | print KEYWORD2 19 | setCursor KEYWORD2 20 | cursor KEYWORD2 21 | noCursor KEYWORD2 22 | blink KEYWORD2 23 | noBlink KEYWORD2 24 | display KEYWORD2 25 | noDisplay KEYWORD2 26 | autoscroll KEYWORD2 27 | noAutoscroll KEYWORD2 28 | leftToRight KEYWORD2 29 | rightToLeft KEYWORD2 30 | scrollDisplayLeft KEYWORD2 31 | scrollDisplayRight KEYWORD2 32 | createChar KEYWORD2 33 | setRowOffsets KEYWORD2 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=LiquidCrystal 2 | version=1.0.7 3 | author=Arduino, Adafruit 4 | maintainer=Arduino 5 | sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). 6 | paragraph=This library allows an Arduino board to control liquid crystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). 7 | category=Display 8 | url=http://www.arduino.cc/en/Reference/LiquidCrystal 9 | architectures=* 10 | -------------------------------------------------------------------------------- /src/LiquidCrystal.cpp: -------------------------------------------------------------------------------- 1 | #include "LiquidCrystal.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Arduino.h" 7 | 8 | // When the display powers up, it is configured as follows: 9 | // 10 | // 1. Display clear 11 | // 2. Function set: 12 | // DL = 1; 8-bit interface data 13 | // N = 0; 1-line display 14 | // F = 0; 5x8 dot character font 15 | // 3. Display on/off control: 16 | // D = 0; Display off 17 | // C = 0; Cursor off 18 | // B = 0; Blinking off 19 | // 4. Entry mode set: 20 | // I/D = 1; Increment by 1 21 | // S = 0; No shift 22 | // 23 | // Note, however, that resetting the Arduino doesn't reset the LCD, so we 24 | // can't assume that it's in that state when a sketch starts (and the 25 | // LiquidCrystal constructor is called). 26 | 27 | LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, 28 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 29 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) 30 | { 31 | init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); 32 | } 33 | 34 | LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, 35 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 36 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) 37 | { 38 | init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); 39 | } 40 | 41 | LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, 42 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) 43 | { 44 | init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); 45 | } 46 | 47 | LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, 48 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) 49 | { 50 | init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); 51 | } 52 | 53 | void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, 54 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 55 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) 56 | { 57 | _rs_pin = rs; 58 | _rw_pin = rw; 59 | _enable_pin = enable; 60 | 61 | _data_pins[0] = d0; 62 | _data_pins[1] = d1; 63 | _data_pins[2] = d2; 64 | _data_pins[3] = d3; 65 | _data_pins[4] = d4; 66 | _data_pins[5] = d5; 67 | _data_pins[6] = d6; 68 | _data_pins[7] = d7; 69 | 70 | if (fourbitmode) 71 | _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; 72 | else 73 | _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; 74 | 75 | begin(16, 1); 76 | } 77 | 78 | void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { 79 | if (lines > 1) { 80 | _displayfunction |= LCD_2LINE; 81 | } 82 | _numlines = lines; 83 | 84 | setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); 85 | 86 | // for some 1 line displays you can select a 10 pixel high font 87 | if ((dotsize != LCD_5x8DOTS) && (lines == 1)) { 88 | _displayfunction |= LCD_5x10DOTS; 89 | } 90 | 91 | pinMode(_rs_pin, OUTPUT); 92 | // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# 93 | if (_rw_pin != 255) { 94 | pinMode(_rw_pin, OUTPUT); 95 | } 96 | pinMode(_enable_pin, OUTPUT); 97 | 98 | // Do these once, instead of every time a character is drawn for speed reasons. 99 | for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i) 100 | { 101 | pinMode(_data_pins[i], OUTPUT); 102 | } 103 | 104 | // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! 105 | // according to datasheet, we need at least 40 ms after power rises above 2.7 V 106 | // before sending commands. Arduino can turn on way before 4.5 V so we'll wait 50 107 | delayMicroseconds(50000); 108 | // Now we pull both RS and R/W low to begin commands 109 | digitalWrite(_rs_pin, LOW); 110 | digitalWrite(_enable_pin, LOW); 111 | if (_rw_pin != 255) { 112 | digitalWrite(_rw_pin, LOW); 113 | } 114 | 115 | //put the LCD into 4 bit or 8 bit mode 116 | if (! (_displayfunction & LCD_8BITMODE)) { 117 | // this is according to the Hitachi HD44780 datasheet 118 | // figure 24, pg 46 119 | 120 | // we start in 8bit mode, try to set 4 bit mode 121 | write4bits(0x03); 122 | delayMicroseconds(4500); // wait min 4.1ms 123 | 124 | // second try 125 | write4bits(0x03); 126 | delayMicroseconds(4500); // wait min 4.1ms 127 | 128 | // third go! 129 | write4bits(0x03); 130 | delayMicroseconds(150); 131 | 132 | // finally, set to 4-bit interface 133 | write4bits(0x02); 134 | } else { 135 | // this is according to the Hitachi HD44780 datasheet 136 | // page 45 figure 23 137 | 138 | // Send function set command sequence 139 | command(LCD_FUNCTIONSET | _displayfunction); 140 | delayMicroseconds(4500); // wait more than 4.1 ms 141 | 142 | // second try 143 | command(LCD_FUNCTIONSET | _displayfunction); 144 | delayMicroseconds(150); 145 | 146 | // third go 147 | command(LCD_FUNCTIONSET | _displayfunction); 148 | } 149 | 150 | // finally, set # lines, font size, etc. 151 | command(LCD_FUNCTIONSET | _displayfunction); 152 | 153 | // turn the display on with no cursor or blinking default 154 | _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; 155 | display(); 156 | 157 | // clear it off 158 | clear(); 159 | 160 | // Initialize to default text direction (for romance languages) 161 | _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; 162 | // set the entry mode 163 | command(LCD_ENTRYMODESET | _displaymode); 164 | 165 | } 166 | 167 | void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3) 168 | { 169 | _row_offsets[0] = row0; 170 | _row_offsets[1] = row1; 171 | _row_offsets[2] = row2; 172 | _row_offsets[3] = row3; 173 | } 174 | 175 | /********** high level commands, for the user! */ 176 | void LiquidCrystal::clear() 177 | { 178 | command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero 179 | delayMicroseconds(2000); // this command takes a long time! 180 | } 181 | 182 | void LiquidCrystal::home() 183 | { 184 | command(LCD_RETURNHOME); // set cursor position to zero 185 | delayMicroseconds(2000); // this command takes a long time! 186 | } 187 | 188 | void LiquidCrystal::setCursor(uint8_t col, uint8_t row) 189 | { 190 | const size_t max_lines = sizeof(_row_offsets) / sizeof(*_row_offsets); 191 | if ( row >= max_lines ) { 192 | row = max_lines - 1; // we count rows starting w/ 0 193 | } 194 | if ( row >= _numlines ) { 195 | row = _numlines - 1; // we count rows starting w/ 0 196 | } 197 | 198 | command(LCD_SETDDRAMADDR | (col + _row_offsets[row])); 199 | } 200 | 201 | // Turn the display on/off (quickly) 202 | void LiquidCrystal::noDisplay() { 203 | _displaycontrol &= ~LCD_DISPLAYON; 204 | command(LCD_DISPLAYCONTROL | _displaycontrol); 205 | } 206 | void LiquidCrystal::display() { 207 | _displaycontrol |= LCD_DISPLAYON; 208 | command(LCD_DISPLAYCONTROL | _displaycontrol); 209 | } 210 | 211 | // Turns the underline cursor on/off 212 | void LiquidCrystal::noCursor() { 213 | _displaycontrol &= ~LCD_CURSORON; 214 | command(LCD_DISPLAYCONTROL | _displaycontrol); 215 | } 216 | void LiquidCrystal::cursor() { 217 | _displaycontrol |= LCD_CURSORON; 218 | command(LCD_DISPLAYCONTROL | _displaycontrol); 219 | } 220 | 221 | // Turn on and off the blinking cursor 222 | void LiquidCrystal::noBlink() { 223 | _displaycontrol &= ~LCD_BLINKON; 224 | command(LCD_DISPLAYCONTROL | _displaycontrol); 225 | } 226 | void LiquidCrystal::blink() { 227 | _displaycontrol |= LCD_BLINKON; 228 | command(LCD_DISPLAYCONTROL | _displaycontrol); 229 | } 230 | 231 | // These commands scroll the display without changing the RAM 232 | void LiquidCrystal::scrollDisplayLeft(void) { 233 | command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); 234 | } 235 | void LiquidCrystal::scrollDisplayRight(void) { 236 | command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); 237 | } 238 | 239 | // This is for text that flows Left to Right 240 | void LiquidCrystal::leftToRight(void) { 241 | _displaymode |= LCD_ENTRYLEFT; 242 | command(LCD_ENTRYMODESET | _displaymode); 243 | } 244 | 245 | // This is for text that flows Right to Left 246 | void LiquidCrystal::rightToLeft(void) { 247 | _displaymode &= ~LCD_ENTRYLEFT; 248 | command(LCD_ENTRYMODESET | _displaymode); 249 | } 250 | 251 | // This will 'right justify' text from the cursor 252 | void LiquidCrystal::autoscroll(void) { 253 | _displaymode |= LCD_ENTRYSHIFTINCREMENT; 254 | command(LCD_ENTRYMODESET | _displaymode); 255 | } 256 | 257 | // This will 'left justify' text from the cursor 258 | void LiquidCrystal::noAutoscroll(void) { 259 | _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; 260 | command(LCD_ENTRYMODESET | _displaymode); 261 | } 262 | 263 | // Allows us to fill the first 8 CGRAM locations 264 | // with custom characters 265 | void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { 266 | location &= 0x7; // we only have 8 locations 0-7 267 | command(LCD_SETCGRAMADDR | (location << 3)); 268 | for (int i=0; i<8; i++) { 269 | write(charmap[i]); 270 | } 271 | } 272 | 273 | /*********** mid level commands, for sending data/cmds */ 274 | 275 | inline void LiquidCrystal::command(uint8_t value) { 276 | send(value, LOW); 277 | } 278 | 279 | inline size_t LiquidCrystal::write(uint8_t value) { 280 | send(value, HIGH); 281 | return 1; // assume success 282 | } 283 | 284 | /************ low level data pushing commands **********/ 285 | 286 | // write either command or data, with automatic 4/8-bit selection 287 | void LiquidCrystal::send(uint8_t value, uint8_t mode) { 288 | digitalWrite(_rs_pin, mode); 289 | 290 | // if there is a RW pin indicated, set it low to Write 291 | if (_rw_pin != 255) { 292 | digitalWrite(_rw_pin, LOW); 293 | } 294 | 295 | if (_displayfunction & LCD_8BITMODE) { 296 | write8bits(value); 297 | } else { 298 | write4bits(value>>4); 299 | write4bits(value); 300 | } 301 | } 302 | 303 | void LiquidCrystal::pulseEnable(void) { 304 | digitalWrite(_enable_pin, LOW); 305 | delayMicroseconds(1); 306 | digitalWrite(_enable_pin, HIGH); 307 | delayMicroseconds(1); // enable pulse must be >450 ns 308 | digitalWrite(_enable_pin, LOW); 309 | delayMicroseconds(100); // commands need >37 us to settle 310 | } 311 | 312 | void LiquidCrystal::write4bits(uint8_t value) { 313 | for (int i = 0; i < 4; i++) { 314 | digitalWrite(_data_pins[i], (value >> i) & 0x01); 315 | } 316 | 317 | pulseEnable(); 318 | } 319 | 320 | void LiquidCrystal::write8bits(uint8_t value) { 321 | for (int i = 0; i < 8; i++) { 322 | digitalWrite(_data_pins[i], (value >> i) & 0x01); 323 | } 324 | 325 | pulseEnable(); 326 | } 327 | -------------------------------------------------------------------------------- /src/LiquidCrystal.h: -------------------------------------------------------------------------------- 1 | #ifndef LiquidCrystal_h 2 | #define LiquidCrystal_h 3 | 4 | #include 5 | #include "Print.h" 6 | 7 | // commands 8 | #define LCD_CLEARDISPLAY 0x01 9 | #define LCD_RETURNHOME 0x02 10 | #define LCD_ENTRYMODESET 0x04 11 | #define LCD_DISPLAYCONTROL 0x08 12 | #define LCD_CURSORSHIFT 0x10 13 | #define LCD_FUNCTIONSET 0x20 14 | #define LCD_SETCGRAMADDR 0x40 15 | #define LCD_SETDDRAMADDR 0x80 16 | 17 | // flags for display entry mode 18 | #define LCD_ENTRYRIGHT 0x00 19 | #define LCD_ENTRYLEFT 0x02 20 | #define LCD_ENTRYSHIFTINCREMENT 0x01 21 | #define LCD_ENTRYSHIFTDECREMENT 0x00 22 | 23 | // flags for display on/off control 24 | #define LCD_DISPLAYON 0x04 25 | #define LCD_DISPLAYOFF 0x00 26 | #define LCD_CURSORON 0x02 27 | #define LCD_CURSOROFF 0x00 28 | #define LCD_BLINKON 0x01 29 | #define LCD_BLINKOFF 0x00 30 | 31 | // flags for display/cursor shift 32 | #define LCD_DISPLAYMOVE 0x08 33 | #define LCD_CURSORMOVE 0x00 34 | #define LCD_MOVERIGHT 0x04 35 | #define LCD_MOVELEFT 0x00 36 | 37 | // flags for function set 38 | #define LCD_8BITMODE 0x10 39 | #define LCD_4BITMODE 0x00 40 | #define LCD_2LINE 0x08 41 | #define LCD_1LINE 0x00 42 | #define LCD_5x10DOTS 0x04 43 | #define LCD_5x8DOTS 0x00 44 | 45 | class LiquidCrystal : public Print { 46 | public: 47 | LiquidCrystal(uint8_t rs, uint8_t enable, 48 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 49 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 50 | LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, 51 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 52 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 53 | LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, 54 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); 55 | LiquidCrystal(uint8_t rs, uint8_t enable, 56 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); 57 | 58 | void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, 59 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 60 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 61 | 62 | void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 63 | 64 | void clear(); 65 | void home(); 66 | 67 | void noDisplay(); 68 | void display(); 69 | void noBlink(); 70 | void blink(); 71 | void noCursor(); 72 | void cursor(); 73 | void scrollDisplayLeft(); 74 | void scrollDisplayRight(); 75 | void leftToRight(); 76 | void rightToLeft(); 77 | void autoscroll(); 78 | void noAutoscroll(); 79 | 80 | void setRowOffsets(int row1, int row2, int row3, int row4); 81 | void createChar(uint8_t, uint8_t[]); 82 | void setCursor(uint8_t, uint8_t); 83 | virtual size_t write(uint8_t); 84 | void command(uint8_t); 85 | 86 | using Print::write; 87 | private: 88 | void send(uint8_t, uint8_t); 89 | void write4bits(uint8_t); 90 | void write8bits(uint8_t); 91 | void pulseEnable(); 92 | 93 | uint8_t _rs_pin; // LOW: command. HIGH: character. 94 | uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. 95 | uint8_t _enable_pin; // activated by a HIGH pulse. 96 | uint8_t _data_pins[8]; 97 | 98 | uint8_t _displayfunction; 99 | uint8_t _displaycontrol; 100 | uint8_t _displaymode; 101 | 102 | uint8_t _initialized; 103 | 104 | uint8_t _numlines; 105 | uint8_t _row_offsets[4]; 106 | }; 107 | 108 | #endif 109 | --------------------------------------------------------------------------------