Using the OLED Touch Screen
Tutorial: Getting Values from the OLED Touch Screen connected to the BCore100 board
What you would need:
Hardware
- BlazingCore100
- 2.83” OLED w/ Touch Screen Interface Board
- Serial Comm.Key
- Power Supply (6V – 9V DC)
Software
Introduction This tutorial aims to provide a walkthrough on how to obtain the X & Y coordinates of a touch on the OLED Touch Screen. For full details on the hardware and software used in this tutorial, head over to the download page and grab a copy of the datasheets and reference materials.
Hardware Setup
Follow the Hardware Setup as illustrated here. Connect the power supply and the Serial Comm.Key (refer to this if you're not sure) and that’s all the hardware we will be using.
Pin Connections
The OLED Touch Screen is a 4 wire resistive touch screen. The 4 I/Os (X-, X+, Y-, Y+) are used; However, since we will be using the library that is written natively in the BCore OS for the OLED interfacing board, no pin definitions are required.
Getting the coordinates Since we know that the screen is a resistive type (analog), we need to convert the values from analog to digital in order to make use of it. The 4 Touch Screen Pins are already connected to ADC (Analog to Digital Conversion) Pins on the BCore. When the command to get the X & Y coordinates is called, the BlazingCore would take care of reading the values from the 4 Pins, do any calculation across the - & + pins, and return the respective X & Y values corresponding to the OLED screen pixel resolution.
The following is a working example of obtaining the X & Y Coordinates from the touch screen, and displaying the values in the Debug Window. The reading is done 5 times per second (1000ms/200ms = 5).
Code:
Public X,Y as Integer Public Sub Main() 'READ ONCE TO INIT TOUCH SCREEN X = OLED.Touch.X() Y = OLED.Touch.Y() Do X = OLED.Touch.X() Y = OLED.Touch.Y() Debug.Print Cstr(X);" ";Cstr(Y) Delay(200) Loop End Sub
When nothing is touching the screen, the value should be (-1) for both axes. When touching the 4 corners of the screen with a stylus or your finger, the values returned should be around those illustrated in the figure below.
|

|
 |
| Optimized Values |
Raw Values |
If your application needs to use the raw readings of the touch screen, use the Raw command instead. The raw values for each touch screen will be slightly different due to its resistive nature. However, it should not be too different from the values illustrated in the figure above.
Code:
Public X,Y as Integer Public Sub Main() Do X = OLED.Touch.Raw.X() Y = OLED.Touch.Raw.Y() Debug.Print Cstr(X);" ";Cstr(Y) Delay(200) Loop End Sub
And that’s it!
See a classic example of how we make use of the touch screen in our application called "The Doodle Blackboard"
Full project source code to read optimized values from the touch screen is available for download below, along with a PDF version of this tutorial.

|