Created
July 30, 2019 01:04
-
-
Save futureshocked/519bf30590f167de0ab2fc678daaa85d to your computer and use it in GitHub Desktop.
This sketch demonstrates how to use the Grove LCD RGB Backlight module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 06.12 - Grove LCD RGB Backlight module, custom characters | |
| * | |
| This sketch demonstrates how to use the Grove LCD RGB Backlight module. | |
| Specifically, it shows how to create and display custom characters. | |
| To create a custom character, you must draw it using pixels. Each character | |
| is drawn on a 8x5 pixel array (8 rows, 5 columns). | |
| For example, a smily emoji would looks like this ("x" is an "off" pixel, | |
| and "o" is an "on" pixel): | |
| x x x x x | |
| x x x x x | |
| x o x o x | |
| x x x x x | |
| x x x x x | |
| o x x x o | |
| x o o o x | |
| x x x x x | |
| Then, you need to encode this pattern as an array of bytes. This array will | |
| contain 8 bytes (one per row). Because we only need 5 pixels, we only need | |
| to specify the first 5 bits of each byte. | |
| The pattern of the smiley custom character becomes this array of bytes: | |
| byte smiley[8] = { | |
| 0b00000, | |
| 0b00000, | |
| 0b01010, | |
| 0b00000, | |
| 0b00000, | |
| 0b10001, | |
| 0b01110, | |
| 0b00000 | |
| }; | |
| Once you have created the custom character array, you can displayed on the LCD | |
| as per the example below. | |
| Components | |
| ---------- | |
| - Grove Base Shield | |
| - An Arduino Uno compatible board (such as Arduino/Genuino Uno or Seeeduino) | |
| - Grove LCD RGB Backlight module | |
| - One Grove cable | |
| IDE | |
| --- | |
| Arduino IDE | |
| Libraries | |
| --------- | |
| - Wire.h (part of the Arduino IDE) | |
| - rgb_lcd.h (Get it from https://github.com/Seeed-Studio/Grove_LCD_RGB_Backlight) | |
| Connections | |
| ----------- | |
| Use a Grove cable to connect the module to Base Shield connector D3. | |
| Other information | |
| ----------------- | |
| - Use this sketch along side the video lecture 06.12 of Grove For Busy People | |
| - Grove documentation: http://wiki.seeedstudio.com/Grove-LCD_RGB_Backlight/ | |
| - Grove component: https://txplo.re/0c9fb | |
| Github Gist | |
| ----------- | |
| <script src="https://gist.github.com/futureshocked/519bf30590f167de0ab2fc678daaa85d.js"></script> | |
| https://gist.github.com/futureshocked/519bf30590f167de0ab2fc678daaa85d | |
| For course information, please go to https://techexplorations.com/product/grove-for-busy-people/ | |
| Created on July 5 2019 by Peter Dalmaris | |
| */ | |
| /* | |
| CustomCharacter.ino | |
| 2013 Copyright (c) Seeed Technology Inc. All right reserved. | |
| Author:Loovee | |
| 2013-9-18 | |
| Grove - Serial LCD RGB Backlight demo. | |
| This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Lesser General Public | |
| License as published by the Free Software Foundation; either | |
| version 2.1 of the License, or (at your option) any later version. | |
| This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| Lesser General Public License for more details. | |
| You should have received a copy of the GNU Lesser General Public | |
| License along with this library; if not, write to the Free Software | |
| Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| */ | |
| #include <Wire.h> | |
| #include "rgb_lcd.h" | |
| rgb_lcd lcd; | |
| // make some custom characters: | |
| byte heart[8] = { | |
| 0b00000, | |
| 0b01010, | |
| 0b11111, | |
| 0b11111, | |
| 0b11111, | |
| 0b01110, | |
| 0b00100, | |
| 0b00000 | |
| }; | |
| byte smiley[8] = { | |
| 0b00000, | |
| 0b00000, | |
| 0b01010, | |
| 0b00000, | |
| 0b00000, | |
| 0b10001, | |
| 0b01110, | |
| 0b00000 | |
| }; | |
| byte frownie[8] = { | |
| 0b00000, | |
| 0b00000, | |
| 0b01010, | |
| 0b00000, | |
| 0b00000, | |
| 0b00000, | |
| 0b01110, | |
| 0b10001 | |
| }; | |
| byte armsDown[8] = { | |
| 0b00100, | |
| 0b01010, | |
| 0b00100, | |
| 0b00100, | |
| 0b01110, | |
| 0b10101, | |
| 0b00100, | |
| 0b01010 | |
| }; | |
| byte armsUp[8] = { | |
| 0b00100, | |
| 0b01010, | |
| 0b00100, | |
| 0b10101, | |
| 0b01110, | |
| 0b00100, | |
| 0b00100, | |
| 0b01010 | |
| }; | |
| void setup() | |
| { | |
| lcd.begin(16, 2); | |
| #if 1 | |
| // create a new character | |
| lcd.createChar(0, heart); | |
| // create a new character | |
| lcd.createChar(1, smiley); | |
| // create a new character | |
| lcd.createChar(2, frownie); | |
| // create a new character | |
| lcd.createChar(3, armsDown); | |
| // create a new character | |
| lcd.createChar(4, armsUp); | |
| #endif | |
| // set up the lcd's number of columns and rows: | |
| lcd.setCursor(0, 0); | |
| // Print a message to the lcd. | |
| lcd.print("I "); | |
| lcd.write((unsigned char)0); | |
| lcd.print(" Arduino! "); | |
| lcd.write((unsigned char)1); | |
| } | |
| void loop() | |
| { | |
| // set the cursor to the bottom row, 5th position: | |
| lcd.setCursor(4, 1); | |
| // draw the little man, arms down: | |
| lcd.write((unsigned char)3); | |
| delay(500); | |
| lcd.setCursor(4, 1); | |
| // draw him arms up: | |
| lcd.write((unsigned char)4); | |
| delay(500); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment