728x90

Create product add-ons using Gravity Forms

With the Gravity Forms Product Add-Ons extension, advanced product configuration forms can be built and linked to any product in WooCommerce. Forms that contain conditional logic, pricing fields, user input prices, conditional-pricing fields, conditional submit button logic can all be created for your products.

Additionally, any product that contains a Gravity Form is tracked in the cart to ensure, no matter how complex your product form, only unique configurations are added to the cart and duplicates are incremented in quantity.

Gravity Forms Product Add-Ons gives you full control over the display of prices in the store. You can use the default price displays provided by WooCommerce, or set the price to ‘As Low as $1000’ in the case of a configurable product containing pricing fields.

You also have control over when the built-in automatic price calculation is displayed, if at all, and can configure each label individually.

This extension requires the Gravity Forms plugin.

 

Setup and Configuration

Required Configuration
The plugin does not require any manual configuration after activation.

Optional Configuration
A setting you might change is how HTML is formatted from specific Gravity Forms field types. A common request is to have HTML from the List type field show as HTML and not as a CSV list of data. To do this, you can use a filter to turn off HTML stripping in the plugin.

To turn off HTML stripping, add the following to the functions.php file in your theme:

add_filter( 'woocommerce_gforms_strip_meta_html', 'configure_woocommerce_gforms_strip_meta_html' );
function configure_woocommerce_gforms_strip_meta_html( $strip_html ) {
$strip_html = false;
return $strip_html;
}

view raw
functions.php
hosted with 

 by GitHub

Getting Started

Build a Gravity Form that contains any of the supported field types. Be sure to leave the Confirmation settings as default text with an empty message. Configure any conditional logic, and optionally submit button logic.

Gravity Forms Product Add Ons does not change or add anything to the actual configuration of the form itself.  The extension will use the form you have already built using the standard method to build a Gravity Form.

To configure the form, do so as though you were creating a form with no connection to WooCommerce.

  • I recommend adding the form to a temporary post or page, or using the Form Preview to get it working properly.
  • Make sure that you submit an entry so you can validate that a regular Gravity Forms submission creates the entry with the correct information
  • Once you have the form configured as required, and after it is attached to a product it will be displayed as you require.

If you need additional assistance with setting up the Gravity Form itself you could check the Gravity Forms Documentation or contact their support team for further assistance on that part.

In the example below, the form is configured to use pricing fields. When using pricing fields, Gravity Forms requires a product and total field. Typically you add a hidden product field to the form and set its price to the price at which you require customizations.

Add a Product field (from the Pricing Fields section) to the form in order to configure the base customization price and set it to $0.00:

Gravity Forms Product Add-On requires that at least one Total field (from the Pricing Fields section) be present on the form. Add a total field to the form. In this example, we are using the built-in dynamic price calculations on our single product page. To prevent the customizations total from being displayed twice on the single product page (once in the dynamically calculated price area and once in the gravity form itself), add a class of “hidden-total” to CSS Class Name under the Appearance tab in the field configuration:

To add options to your form, use the Option field type from Gravity Forms.  You can use other controls, such as the standard dropdown, but you must use the option field if your option has a cost associated.

Note: If you have options that have a cost associated, you must use the Product Option field type, not standard drop-down fields, radio buttons, checkboxes, etc.  This is standard for how Gravity Forms works. If you have trouble creating the product form, Gravity Forms documentation has several good examples.

Once you have built your form and are satisfied with the functionality, create or edit an existing WooCommerce product. Please note that in order for the form to display on the front end, you will need to have either a price or a 0 in the Regular Price field (for more information, see FAQ below).

Select the form you wish to use.

With Gravity Forms Add-On enabled, you have options for linking the form, displaying the Gravity Form title and description, and displaying alternative price titles throughout the store. You also have the ability to control how the dynamically calculated price is displayed on the single product page.

Price Labels

Remove WooCommerce Price

This will remove the price html from the store when viewing the product.  Use this option if you are doing all calculations in the form and do not want 0 or Free to display as the products regular price.

Price Before

A label which can be added before the price.  Useful for adding information to the price section on the product letting your customers know the price is the base price, and additional form options will add to the total cost.

Price After

A label to display after the regular price in your store.

Total Calculations

Enable Dynamic Pricing

This option will be visible if you have the WooCommerce Dynamic Pricing plugin active.  By setting this to Yes, the price visible to your customers will automatically update based on pricing rules and the cost of the customers selected options.

Disable Calculations

To completely remove the Subtotal, Options Total and Grand Total section from your products.  Useful if you are not performing any calculations and have no fields on your form which add to the products cost.

Disable Subtotal

Will remove the Subtotal line from the totals section on your product page.

Subtotal Label

The label to display for the Subtotal line item.

Disable Options Total

Will remove the Options total, the price added to the product by your form options, line from the totals section on your product page.

Options Label

The label to display for the Options line item.

Disable Total Label

Will remove the Total, the price of your product plus the price added to the product by your form options, line from the totals section on your product page.

Total Label

The label to display for the Total line item.

Entries and Notifications

Keep Cart Entries

As of Gravity Forms 3.3, entries are only created when the order is placed.  In previous versions entries were created as a side effect of creating the cart item.  These entries are now removed by default automatically.  If you would like to track both the entries created when someone is adding an item to their cart check Keep Cart Entries.

Note, normally this is not very useful since you have no link between the entry and the cart to which it was added.

The entries created during the actual checkout process are properly linked to their associated order items.

Update Payment and Transaction Details

Check this box to enable the transactional data link between the Gravity Form entry and the WooCommerce order.  When enabled transaction information, such as payment status and order details, will be linked to the entry automatically.  The information will update as the order and payment status change in WooCommerce.

Send Notifications

Gravity Forms Product Addons automatically disables any notifications from being sent when items are ordered and entries are created.

If you would like to process your notifications, enable this option.   When orders are created you will receive the notifications you have configured for each cart item which has a form attached to it.

Advanced Options

Enable Cart Edit

Enable this to allow users to edit items they have added to their cart.  The default would be the user would need to fill out a form and add it to the cart, and manually remove any items on which they want to change.  If you enable cart edit users can click on the item in the cart to be taken back to the product page with their details pre-filled out.

Replace Modified Items

Choose to Replace the edited item or to add a new item to the cart.  Normally you would want to replace the modified item, since the user is editing it, however the option now exists to append the modified item.

Quantity / Stock Options

If your form has the right type of fields you can enable the form to be linked to either the Cart Quantity or the final Order Item Quantity.  This could be useful if you have quantity fields on your form itself and want to use that value when the customer adds the item to the cart.

If you would just like to reduce the stock quantity of your WooCommerce product based on a field on the form, choose Order Item Quantity.  The cart quantity will remain 1 but when the order is placed the stock quantity of the product will be reduced by the value of the field you choose.

 

After your options have been configured, publish or update your product. Navigate to the product in the store and see how your form has been linked to the product:

When a customer purchases a product linked to a Gravity Form, here is how the add-on information displays:

Cart View

Order Confirmation

Admin Email – New Order Notification

WooCommerce Order Information

Gravity Forms Product Addons 3.3 now links each order item to the Gravity Form entry created during the checkout process.  Once the order is placed you can quickly jump from the WooCommerce order to the associated entry.

Gravity Form Entry Information

Gravity Forms Product Addons 3.3 adds additional information to the entries inside of Gravity Forms itself.   This allows you to quickly see the associated WooCommerce order information.

Each cart item ordered will have a 1-1 relationship to it’s entry.

The entries themselves will have additional data provided by the parent WooCommerce order.

Gravity Form Entry Transaction Information

The entries are linked to their respective WooCommerce order item and will update it’s status and transaction information as the order proceeds through the order and payment process.  This is useful if you want to export your entries and only work with items with a specific order status.

Supported Gravity Form Fields and Features

Standard Fields

  • Single Line Text
  • Drop Down
  • Number
  • Radio Buttons
  • HTML
  • Paragraph Text
  • Multi Select
  • Checkboxes
  • Hidden
  • Section Break

Advanced Fields

  • Name
  • Time
  • Address
  • Email
  • Date
  • Phone
  • Website
  • File Upload
  • List ( Partial support, the column values are stored in WooCommerce as a CSV list of data, not the raw HTML )

Pricing Fields

  • Product
  • Option – Drop Down
  • Option – Check-boxes
  • Option – Radio buttons
  • Total
  • Quantity
  • Shipping

Forms that are AJAX-enabled are not currently supported with Gravity Forms Product Add-Ons

Quick Tips

  • Any license level of Gravity Forms will work with this extension.
  • If you are having trouble with a form, calculations or conditional logic, ensure that the form works as expected on a regular post or page.  Often times, calculated fields or conditional logic is not configured as expected and it’s easier to track this down when using the gravity form alone and without an attached product.
  • Ensure that you avoid using custom confirmation settings on the form.  Leave the default confirmation set to text with an empty message.

FAQ

What is the best way to use these forms while keeping my website fast?

Make each individual product into a separate Gravity Form Page. Using conditional logic on each separate product page (rather than providing every variable possible on one page) will keep your website fast. Each field that has conditional logic requires an AJAX post back, so there will be only five rather than 25 fields with conditional logic. Using the multipage approach should take care of lag issues.

Why are duplicate entries created?

Gravity Form Add-Ons no longer creates duplicate entries.  Entries are created during the add to cart process, however they are automatically removed.   Once the actual order is completed an entry will be created and will be linked to the ordered item.   When viewing the order you will see a link to the entry and when viewing the entry you will see a link to the WooCommerce Order.

Why won’t Gravity Forms show on the front end?

Products that have an empty ‘price’ field won’t display Gravity Forms Add-Ons. Enter a value as shown:

 

The Gravity Form will also not display if you have any fatal JavaScript errors on your site caused by your theme or other plugins.  Gravity Forms itself uses JavaScript to display the form, and if there is a fatal script error before the form is completely rendered it won’t be displayed.    You can check for this condition by using Google Chrome Developer Tools and checking the Console to see if there are any errors.   If there are you should contact the Theme or Plugin Author to help resolve those.

Can I use Gravity Forms Add-Ons to send emails?

Gravity Forms will not send notifications you have configured once the order is completed.  This is a recent change as of version 3.3.   If you want to receive Admin Notifications you can enable those when configuring the form options on your WooCommerce product.

Why do my forms redirect to a page URL that ends with /:/?

Ensure that you are running the latest version of Gravity Forms and Gravity Forms Product Add-Ons. If this is still an issue, delete the problematic form and create it again from scratch. Use the new form.

Why are my Options and Totals not correctly adding costs?

There are a few possibilities. The first is that you must check that you are assigning each option field to a product field. Next ensure that you have Disable quantity field checked for the product field if this option is not used.

Why doesn’t this work with the Gravity Forms Partial Entries add-on?

Partial Entries is a 3rd party add-on for Gravity Forms, which collects data for partially completed, but not submitted, forms. Since the actual form entries for Gravity Forms are not important to the WooCommerce cart / order process (see FAQ re: duplicate entries), this add-on is not compatible with our Gravity Forms Product Add-ons extension.

Why are my calculations not showing?

In some cases it may be due Ajax being disabled. It may also be a plugin/theme conflict. More at: WooCommerce Self-Service Guide.

Can I use the form fields to change the product’s featured image like I do with product variations?

No, Gravity Forms does not allow to link fields and their values with product variations.

Where can I see Gravity Forms Product Add-Ons in action?

There is a demo showing:

Questions & Support

Have a question before you buy? Please fill out this pre-sales form.

Already purchased and need some assistance? Get in touch with the developer via the Help Desk.

 

 

docs.woocommerce.com/document/woocommerce-gravity-forms-product-addons/

728x90
728x90

1602(16x2) 또는 2004(20x4) 크기의 CLCD(Character LCD)는 텍스트 LCD(Text LCD)라고로 부르는데요. 최소로 제어해야 하는 핀이 6개여서, CLCD를 제어하려면 MCU의 핀이 최소한 6개가 필요합니다. 그런데 SPI 방식이나 I2C 방식의 port extender IC를 사용하면 각각 4개, 2개의 MCU 핀으로도 제어할 수 있어서, 제어핀의 갯수가 줄어드는 이점이 있어요. 그래서 이전 글에서 PCF8574 port extender IC가 있는 확장보드를 CLCD에 납땜으로 연결한 뒤, STM32F746 MCU로 구동했습니다.

 

이전 글: PCF8574 I/O 확장보드를 사용한 CLCD(Text LCD) 구동 (STM32F746, I2C)

 

 

 

이 글에서는 I2C 방식의 CLCD를 아두이노 레오나르도로 제어하기 위해, STM32F746에 올렸던 코드를 아두이노용으로 살짝 바꿨습니다. 같은 확장보드가 연결된 CLCD를 제어해서, 제어논리를 똑같이 쓸 수 있어서 코드의 논리적인 부분은 바꿀 필요가 없었습니다. ST사의 HAL 함수를 아두이노의 해당 함수로 바꾸고, 8자리 I2C 주소를 7자리 I2C 주소로 바꾸고, 그리고 CLCD에 나타낼 문자열을 바꾸는 것이 거의 전부였어요. 한 MCU에서 완성시킨 코드를 다른 MCU에도 쉽게 변형해서 사용할 수 있었습니다. 여기서부터는 CLCD 대신 텍스트 LCD(text LCD)라고 부르겠습니다.

 

 

 

1. 동작 동영상

 

PCF8574 확장보드의 VCC, GND, SCL, SDA 핀은 각각 아두이노 레오나르도의 5V, GND, SCL, SDA 핀에 연결했습니다. 그래서 PCF8574는 아두이노로부터 I2C 신호를 SCL, SDA 버스를 통해 받고, 5V 전원도 공급받아 텍스트 LCD에 전원을 공급합니다. PCF8574와 아두이노 레오나르도의 USB 케이블은 스위치가 있는 USB 아답터에 연결했습니다. 동영상의 2초 정도에 스위치를 눌러 아두이노 레오나르도에 전원을 공급하면, 텍스트 LCD가 켜지고 조명이 깜박이는 것을 볼 수 있어요. STM32F746으로 텍스트 LCD를 구동했을 때와 똑같이 동작시켰습니다.

 

 

  •  

 

PCF8574 I2C 확장보드로 CLCD, Text(텍스트) LCD 구동 (아두이노)

재생 수542

 

 

 

 

 

 

 

 

  

화질 선택 옵션1080p

 

 

 

 







2. PCF8574 I/O 확장보드와 회로도

 

아래 사진은 같은 PCF8574 모듈이 부착된 텍스트 LCD를 제어했던 이전 글에서 가져왔습니다. 위 동영상의 텍스트 LCD도 PCF8574 모듈이 사진처럼 연결되어 있어요. 모듈의 IC는 PCF8574 의 여러 시리즈 중 PCF8574T 이고요. 제가 사용한 코드는 STM32F746 MCU로 동작시키면서 검증이 되어서, 프로브가 연결된 사진과 다르게 이 글에서는 로직 아날라이저로 신호를 측정하지 않았습니다.






PCF8574 보드의 회로도 역시 이전 글에서 가져왔습니다. PCF8574를 사용한 확장보드는 여러 종류가 있어서, PCF8574와 텍스트 LCD가 어떻게 연결되어 있는지 회로도를 잘 봐야해요. 저 아래에 나오는 코드의 함수는 텍스트 LCD의 D[7:4]핀이 PCF8574의 P[3:0]핀에 연결된 경우 그대로 사용할 수 있습니다. D[7:4]핀이 P[7:4]에 연결된 경우는 함수를 수정해야 CLCD를 구동할 수 있어요. 어떤 확장보드는 텍스트 LCD의 A핀이 VCC에 연결되어 백라이트가 항상 켜지는 경우도 있는데, 이 경우 LCD의 백라이트 on/off 제어는 안됩니다. A[2:0]핀의 납땜상태는 GND에 연결된 상태로 그대로 놔둬서, PCF8574의 I2C 주소는 이전글과 똑같이 0x20 입니다. I2C 버스로 PCF8574의 주소와 함께 write 비트를 전송하고 나면, 그 뒤에 8비트 값이 전송될때마다 PCF8574의 P[7:0]출력상태가 바뀝니다. 8비트 값이 그대로 P[7:0]핀의 출력상태가 되어, 텍스트 LCD를 I2C 신호로 제어할 수 있어요. 자세한 내용은 PCF8574의 데이터시트를 보면 알 수 있습니다.








3. HD44780의 명령어와 DDRAM 주소

 

아래에 표로 설명된 명령어는 텍스트 LCD의 구동 IC인 HD44780의 데이터시트에 나옵니다. 텍스트 LCD의 E핀에 하강엣지가 입력될 때, 다른 핀의 상태에 따라 다른 명령어가 입력됩니다. 아두이노가 아래 코드를 통해 텍스트 LCD에 입력하는 명령어는 이 표를 보고 해석하면 돼요. 빨간 밑줄로 표시된 명령어는 DDRAM의 주소를 텍스트 LCD에 입력합니다.






1602(16x2) 크기의 텍스트 LCD의 위치에 따른 DDRAM의 주소는 아래와 같습니다. 입력되는 DB7(D7) 핀의 상태가 high여서 Set DDRAM address 명령어가 LCD에 입력될 때, 8비트 모드이면 표처럼 DB[6:0] 또는 D[6:0] 핀에 따라 주소가 결정돼요. 4비트 모드이면 주소가 D[7:4]핀으로 두번 전송됩니다. DDRAM 주소는 바로 다음에 문자를 출력할 위치를 가리키고, 문자가 한개씩 출력될때마다 1씩 증가해서 다음 위치를 가리킵니다. 그래서 LCD_String( ) 함수에 문자열을 입력하면, 문자열의 문자가 바로 옆 위치로 순서대로 출력됩니다. 다른 글에서 사용된 2004(20x4) 크기의 텍스트 LCD는 4줄로 구성되어 있는데요. 눈으로는 4줄이지만, 제어는 40x2 크기의 2줄 형태로 해야해요. HD44780으로 구동되는 텍스트 LCD는 1줄 또는 2줄 모드로 제어해야 하고, 4줄 모드의 제어방식은 없습니다.

 






4. 아두이노에 올린 코드

 

텍스트 LCD를 동작시키기 위해 아두이노에 올린 코드는 아래와 같습니다. I2C 방식으로 동작하는 PCF8574 IC를 통해 텍스트 LCD를 제어하기 때문에, I2C 라이브러리가 있는 Wire.h 파일을 include 했습니다. 제가 LCD 제어를 위해 직접 작성한 함수를 사용하기 위해, 많은 사람들이 사용하는 LiquidCrystal_I2C.h 파일은 include하지 않았습니다. Initialize_LCD( ) 함수는 텍스트 LCD를 초기화하기 위해 필요한데, HD44780 데이터시트에 나온 초기화 과정대로 함수의 코드를 작성했습니다. LCD_string( ) 함수의 주소를 입력하는 부분에 0x80을 더한 이유는, 위 표처럼 DDRAM의 주소를 설정하는 명령어가 0x80으로 시작하기 때문입니다. 아래 코드에 대한 더 자세한 설명은 주석에서 볼 수 있어요.

 

#include "Wire.h"  // I2C library

 

uint8_t I2C_addr_PCF8574 = 0x20 // I2C address of PCF8574

 

void I2C_LCD_command_8(unsigned char command); // 8-bit command to text LCD

void I2C_LCD_command(unsigned char command);   // 4-bit command to text LCD

void I2C_LCD_data(unsigned char data);         // Transfer 1 character to text LCD

void LCD_string(unsigned char command, char *string);  // Transfer string to text LCD

void Initialize_LCD(void);  // Initialize text LCD

 

 

 

void setup()

{

    char str0[] = "PCF8574 I2C CLCD";

    char str1[] = "Arduino Leonardo";

 

    Wire.begin(); // Initialize I2C bus

    delay(100);

    Initialize_LCD(); // Initialize Text LCD

 

    // 0x80: Set DDRAM address instruction

    LCD_string(0x80, str0); // 0x80: the 1st position in the 1st row

    LCD_string(0x80 + 0x40, str1); // 0x80 + 0x40: the 1st position in the 2nd row

}

 

 

 

void loop()

{

    uint8_t Backlight[] = {0x80, 0x00}; // off, on

    delay(500);

 

    // LCD backlight off

    Wire.beginTransmission(I2C_addr_PCF8574); ); // Send address to PCF8574

    Wire.write(Backlight[0]); // Transfer 0x80 signal (BJT off) to text LCD

    Wire.endTransmission();   // Transfer I2C stop signal to PCF8574

 

    delay(500);

 

    // LCD backlight on

    Wire.beginTransmission(I2C_addr_PCF8574); // Send address to PCF8574

    Wire.write(Backlight[1]); // Transfer 0x00 signal (BJT on) to text LCD

    Wire.endTransmission();   // Transfer I2C stop signal to PCF8574

}

 

 

 

void I2C_LCD_command_8(unsigned char command) // write a command(instruction) to text LCD

{

    //P0: D4  P1: D5  P2: D6  P3: D7

    //P4: E   P5: RW  P6: RS  P7: BJT base

 

    uint8_t T_buf[2]; // transmit buffer

 

    T_buf[0] = (command >> 4) | 0x10; // high 4 bit, E = 0, RS = 0, base = low (Backlight on)

    T_buf[1] = T_buf[0] & 0xEF;       // E = 0

 

    Wire.beginTransmission(I2C_addr_PCF8574); // Send address to PCF8574

    Wire.write(T_buf[0]);   // Transfer buffer to text LCD via PCF8574

    Wire.write(T_buf[1]);

    Wire.endTransmission(); // Transfer I2C stop signal to PCF8574

}

 

 

void I2C_LCD_command(unsigned char command) // write a command(instruction) to text LCD

{

    //P0: D4  P1: D5  P2: D6  P3: D7

    //P4: E   P5: RW  P6: RS  P7: BJT base

 

    uint8_t T_buf[4]; // transmit buffer

 

    T_buf[0] = (command >> 4) | 0x10; // high 4 bit, E = 1, RS = 0, base = low (Backlight on)

    T_buf[1] = T_buf[0] & 0xEF;       // E = 0

 

    T_buf[2] = (command & 0x0F) | 0x10; // low 4 bit, E = 1

    T_buf[3] = T_buf[2] & 0xEF;         // E = 0

 

    Wire.beginTransmission(I2C_addr_PCF8574); // Send address to PCF8574

    Wire.write(T_buf[0]);   // Transfer buffer to text LCD via PCF8574

    Wire.write(T_buf[1]);

    Wire.write(T_buf[2]);

    Wire.write(T_buf[3]);

    Wire.endTransmission(); // Transfer I2C stop signal to PCF8574

}

 

 

void I2C_LCD_data(unsigned char data) // display a character on text LCD

{

    //P0: D4  P1: D5  P2: D6  P3: D7

    //P4: E   P5: RW  P6: RS  P7: BJT base

 

    uint8_t T_buf[4]; // transmit buffer

 

    T_buf[0] = (data >> 4) | 0x50;   // high 4 bit, E = 1, RS = 1

    T_buf[1] = T_buf[0] & 0xEF;      // E = 0

 

    T_buf[2] = (data & 0x0F) | 0x50; // low 4 bit, E = 1, RS = 1

    T_buf[3] = T_buf[2] & 0xEF;      // E = 0

 

    Wire.beginTransmission(I2C_addr_PCF8574); // Send address to PCF8574

    Wire.write(T_buf[0]);   // Transfer buffer to text LCD via PCF8574

    Wire.write(T_buf[1]);

    Wire.write(T_buf[2]);

    Wire.write(T_buf[3]);

    Wire.endTransmission(); // Transfer I2C stop signal to PCF8574

}

 

 

void LCD_string(unsigned char command, char *string) // display a string on LCD

{

    I2C_LCD_command(command); // start position of string

    while (*string != '\0')   // display string

    {

        I2C_LCD_data(*string);

        string++;

    }

}

 

 

void Initialize_LCD(void) // initialize text LCD module

{

    // 8-bit mode

    I2C_LCD_command_8(0x30);

    delay(10);

    I2C_LCD_command_8(0x30);

    delay(6);

    I2C_LCD_command_8(0x30);

    I2C_LCD_command_8(0x20); // changes to 4-bit mode

 

    // 4-bit mode

    I2C_LCD_command(0x28); // function set(4-bit, 2 line, 5x7 dot)

    I2C_LCD_command(0x0C); // display control(display ON, cursor OFF)

    I2C_LCD_command(0x06); // entry mode set(increment, not shift)

    I2C_LCD_command(0x01); // clear display

    delay(3);

}

 

 

 

I2C 방식의 PCF8574 확장보드가 연결된 텍스트 LCD는 아두이노로 이렇게 구동할 수 있습니다. 제가 텍스트 LCD를 다른 MCU로 구동하는 코드를 이미 작성해서 가지고 있어서, LiquidCrystal_I2C.h 헤더파일을 사용하는 대신 기존의 코드를 조금만 수정해서 손쉽게 텍스트 LCD를 동작시켰습니다. 제가 직접 작성한 코드를 사용해서 신뢰감이 더 느껴지는군요. 텍스트 LCD를 STM32F746 MCU로 구동한 이전 글의 코드와 비교하면, 이 글의 코드는 거의 복사 + 붙여넣기 수준입니다^^

 

이 글에서는 I2C 핀과 텍스트 LCD의 각 핀의 신호를 로직 아날라이저로 측정하지 않았는데요. 각 핀으로 전달되는 신호를 보고 싶으시면, 같은 방식으로 텍스트 LCD를 구동했던 이전 글의 로직 아날라이저 화면을 보세요. 이 글과 이전 글은 확장보드와 I2C 클럭 주파수가 같고 코드도 유사해서, 신호도 거의 같습니다.

 

이전 글: PCF8574 I/O 확장보드를 사용한 CLCD(Text LCD) 구동 (STM32F746, I2C)

'홍익인간 프로젝트 > Arduino C' 카테고리의 다른 글

What's means F() function ?  (0) 2021.01.14
u8g2setupcpp  (0) 2020.12.25
LiquidCrystal I2C - 3 Arguments Type  (0) 2020.12.25
Software Serial Example  (0) 2020.12.16
Arduino Uno TM1637 Display  (0) 2020.12.16
728x90

 

 

 

그림1. LCD 1602(16X2) 4(I2C제어) 디스플레이 모듈

 

 

 

  LCD 1602(16x2) 4(I2C제어) 디스플레이 모듈

 

LCD 가장보편적이고초보자, 입문자분들이쉽게활용할있는모델인LCD 1602 입니다. 또한 16핀의제어핀을LCD뒤에부착된I2C변환모듈을통해 4개의핀으로제어가가능하도록쉽게만들어진모델입니다.

 

 

 

그림2. LCD 1602(16X2) 4(I2C제어) 디스플레이 모듈 핀맵

 

 

 

 

 

LCD 1602(16x2) 4(I2C)제어 레이 모듈 보러가기(클릭)

 

 

 

 

 

1. LCD 1602(16x2) 4(I2C)제어 디스플레이 모듈  

 

쉽게사용할있는 4모델로I2C통신을통해제어되는 LCD 디스플레이모듈입니다. 해상도는16x2 케릭터(Character Type)입니다.

 

디스플레이 타입(Display Type)

LCD(Liquid Crystal Display)

동작 전압(Operating Volate)

5V

해상도(Resolution)

16x2

I2C 주소

0x3F or 0x27

통신 인터페이스

I2C 통신 지원

백라이트

파란색(Blue)

색상

흰색(White)

소비전력

0.4W

무게(Weight)

3.2g

크기(Size)

82 x 35 x 18mm

 

 

 

2. 라이브러리 다운로드  설치하기  

 

LCD_I2C사용하기위해서는라이브러리를다운받아야합니다. 다운경로는아래와같습니다.

 

 

 

LCD I2C 라이브러리 다운받기(클릭)

 

 

 

 

 

 

다운받은 ZIP파일안에들어있는폴더를컴퓨터의아두이노 IDE 설치경로로들어가아래그림과같이라이브러리폴더아래에복사해넣어줍니다. 아두이노 IDE껐다실행하면자동으로아래경로의라이브러리가포함되어실행됩니다.

 

 

 

 

 

 

 주의사항

  - 라이브러리 추가시 경로설정을 정확하게 해야합니다.

    아래 그림과 같이 ' C:\Program Files (x86)\Arduino\libraries\LiquidCrystal_I2C-master ' 경로 안에

    example 폴더와 헤더파일을 포함한 파일들이 들어있어야 합니다.

    (경로설정을 잘못하면 아두이노 IDE에서 컴파일 오류가 발생할 수 있습니다.)

 

 

 

 

 

 

 

3. 회로도 구성  

 

아두이노우노와I2C 통신을구성해봅시다. 회로도는아래와같이연결해줍니다.

 

5V – VCC

GND – GND

A4 – SDA

A5 - SCL

 

 

 

 

4. 예제 따라하기1 – Hellow world  

 

 이제디스플레이해봅시다!!

 

 

예제소스는다음과같습니다.

 

#include <Wire.h>                        // i2C 통신을 위한 라이브러리

#include <LiquidCrystal_I2C.h>        // LCD 1602 I2C 라이브러리

LiquidCrystal_I2C lcd(0x3F,16,2);     // 접근주소: 0x3F or 0x27

void setup()

{

  lcd.init();                      // LCD 초기화

  // Print a message to the LCD.

  lcd.backlight();                // 백라이트 켜기

  lcd.setCursor(0,0);             // 1번째, 1라인

  lcd.print("Hello, world!");

  lcd.setCursor(0,1);             // 1번째, 2라인

  lcd.print("Enjoy - Eduino");

}

void loop()

{

}

 

실제동작모습은다음과같습니다.

 

 

 

그림3. LCD 1602 4핀제어 디스플레이 모듈 실행 예제1. Hellow world

'홍익인간 프로젝트 > Arduino C' 카테고리의 다른 글

u8g2setupcpp  (0) 2020.12.25
PCF8574 I2C 확장보드로 CLCD, Text(텍스트) LCD 구동 (아두이노)  (0) 2020.12.25
Software Serial Example  (0) 2020.12.16
Arduino Uno TM1637 Display  (0) 2020.12.16
Arduino Basic  (0) 2020.12.12

+ Recent posts