Programming the Arduino in BASIC - Using the Shield LCD Keypad Part. 2
Let's continue : using GCBasic with the LCD shield.
GCBasic directly manipulates the microcontrollers' hardware ports (PORTB, PORTC, etc.).
The basic Arduino Uno board uses an Atmel Mega328p clocked at 16 MHz.
The Arduino Uno board has numerous input/output ports numbered from 0 to 19 (blue).
The pin nomenclature is slightly different between the Arduino IDE and GCB (yellow).

To save digital pins, the buttons are connected to a single analog pin (AN0) via a voltage divider, which allows the analog value corresponding to each button pressed to be read.
With CGB, the LCD screen requires the following pin numbers to be assigned:
RS=portB.0, EN=portB.1, D4=portD.4, D5=portD.5, D6=portD.6, D7=portD.7, RW on Gnd
A potentiometer on the shield allows you to adjust the display contrast (Backlight adjustement).
The pins not used by the screen allow you to easily connect sensors or other components.

In the demo files, select LCDCURSOR_4WIRE_TEST_mega328p.gcb
C:\GCstudio\gcbasic\demos\LCD_Solutions\Four_Wire_LCD_Solutions\LCDCURSOR_4WIRE_TEST_mega328p.gcb
To avoid modifying the demo file, save it in a specific file (e.g., GCB_LCD.gcb).
It is essential to modify the RS and Enable terminals for the Shiel LCD:

Click on Make Hex and Flash
The LCD display activates...
This gives an overview of the possibilities of the LCD library
Another tests
For the remainder of my tests, I installed a connector to provide an I2C port.
On the Arduino, the SDA line is on PC4 and the SCL line is on PC5. Note the pull-up resistors.
I also installed a beeper on PC1.

Using the Shield LCD Keypad and a Ds18B20 - Temperature measurement
Installation of a terminal at the port Use of a DS18B20 temperature sensor

In the demo files, select Temperature_Sensor_to_LCD_mega168.gcb
C:\GCstudio\gcbasic\demos\Temperature_Sensor_Solutions\DS18B20_Sensor_Solutions\Sensor_to_LCD\4Wire_LCD
To avoid modifying the demo file, save it in a specific file (GCB_18B20)...
You will need to change the circuit and specify #chip mega328p, 16.
It is essential to modify the RS and Enable terminals.
It is essential to specify the port to be used, A5, i.e., PC.5 with #define DQ PortC.5.
Note the use of the ds18b20 library with #include <ds18b20.h>.
About the GCBasic libraries
As with the Arduino IDE, which uses libraries to manage specific sensors or modules, GCBasic works with #include files.
These files are already provided in the C:\GCstudio\gcbasic\include folder, so there is nothing to download.
There are two types of libraries:
- Internal (low-level) libraries: these correspond to standard PIC peripherals (USART, I²C, timers, text LCD, etc.). They are automatically integrated by the compiler when an associated command is used (PrintLCD..., I2CStart, etc.), so there is no need to include them manually.
- Specific (high-level) libraries: these relate to specific sensors or modules (e.g. DS18B20, DHT11, ILI9341 displays, ST7735, etc.). In this case, you need to add an #include directive to your program.
If a library does not exist for your hardware, you can ask for help on the GCBasic forum, where the community often provides examples or new libraries.

Discussion (1 comment)