80s toys - Atari. I still have
Background To Stone Technology And Setting Up RGB ControlCustom page

Background To Stone Technology And Setting Up RGB Control

In the previous post, we all seen basics of STONE TFT display interface and how to use for our embedded application, in this post we will be going to use same display for control our RGB led strip and we going to ON or OFF light using a display touch interface, so let's get started with the setup of our new project.

For our setup we required.

  1. STONE TFT display
  2. Display USB cable for programming.
  3. Arduino UNO
  4. Some wires for connection.
  5. WS2812 LED strip
  6. 12V or 5V DC supply.
  7. RS323 to TTL

So I already have all set up with me, i will first prepare STONE HMI UI.

So we go to HMI display TOOL4.3 and start a new project call RGB_LED, and add an image which includes our 2 buttons ON/OFF.

Step 1: we create one image with background and 2 buttons ON and OFF, shown as below image and add as an image in our project.

1

Step 2: And then we add return press by key-value shape over our button shape, this is basically control which is going to send some hex value to our Arduino board when someone is touch this button shape, we do this same off OFF button also.

Step 3: Now we need to indicate user also so he/she comes to know he touched button so we need to add button effect on press for that we need to add an image with updated color code of button to blue,

we create this image in some image editor and add a picture as a jpg file to out software.

2

Step 4: So we already add our effect image in tool now we need to config it, so for that, we are going to update our button property for that, you need to click to button square box and then go to right side Atributr setting window, in that button property you get one member called "Button effect", this setting you need to select our second image from drag and drop menu.

Step 5: And for identifying both button event we need to provide key-value fro both button and it should be Unique hex number, as we have only 2 buttons we provide key for ON=01 and OFF=02.

3

Step 6: Need to build and download this project to out HMI display, i think you all already gone three my previous tutorial part-1, all process-related that is already explained in this tutorial.

Step 7: We need to test the button press event next data with our tool to ensure what we configured is working or not before the jump to the Arduino project, so for that, you just need to plug HMO display with the serial module and then connect this serial module to your PC and click to serail icon as shown in below screen, you will get one popup screen on that you need to select the appropriate serial port and click on open, after that you need to touch to display button when you touch to button you will get on hex stream on display, the last byte of the stream is key of a button which you set in the project.

4

Now our display setup is done we need to set up our Arduino board hardware first, set up hardware as below image.

5

Now time to code our Arduino as per Hex stream which we tested, and also we need to control our LED strip also.

For programming, we are going to use platform IO with the VS code, i am like this setup because it is convenient to use.

This is Code i made for this project.

main.c

 

1

 2

 3

 4

 5

 6

 7

 8

 9

10

#include <Arduino.h>#include <Adafruit_NeoPixel.h>#include <SoftwareSerial.h>

#define PIN 6

SoftwareSerial softserial(23);

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);char RxData[15];unsigned char arrIndex = 0;unsigned char index = 0;

void setup() {

  Serial.begin(115200);

  softserial.begin(115200);

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

 strip.begin();

  strip.show();

}

void loop() {

  if(softserial.available())

  {

    RxData[arrIndex] = softserial.read();

    //Serial.print(RxData[arrIndex]);

    arrIndex++;

    

    if (arrIndex >= 9) {

      if(RxData[8] == 0x01)

      {

        strip.fill(strip.Color(255255255), 060);

        strip.show();

      }

      

      if(RxData[8] == 0x02)

      {

        strip.clear();

        strip.show();

      }

      

      for(int i = 0; i < 9; i++)

      {

        Serial.print(RxData[i]);

      }

      arrIndex = 0;

    }

  }

}

platformio.ini

1

2

3

4

5

[env:uno]

platform = atmelavr

board = uno

framework = arduino

lib_deps = Adafruit NeoPixel

Now just use the above code and build and program you Arduino Uno.

6

This is a video of the final test of our project.

https://youtu.be/uWgysGXv8fs