Servo-Motor using Arduino with STONE-HMI display

Description

In electronics projects, creating an interface between user and system is very important. This interface could be created by displaying useful data, a menu, and ease of access. A beautiful design is also very important. There are several components to achieve this like TFT Displays. For more information Click Here.

TFT LCD is a variant of a liquid-crystal display (LCD) that uses thin-film-transistor (TFT) technology to improve image qualities such as addressability and contrast. This can be achieved by TFT display provided by STONE Technologies. They are a professional manufacturer of HMI (Human-Machine Interface) Intelligent TFT LCD module. Their core TFT LCD display modules integrate a CPU, flash memory, and touch screen in the hardware unit. Paired with an easy-to-use free GUI design software and complete instruction set for more click here.

Circuit Diagram

For information about the TFT display visit Stone website Click Here.

Working

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino. The potentiometer should be wired so that its two outer pins are connected to power (+5V) and ground, and its middle pin is connected to analog input 0 on the board.

To purchase the product used in this project Click Here.

The Arduino hardware has built-in support for serial communication on pins 0 and 1 (which also goes to the computer via the USB connection). This hardware allows the Atmega chip to receive serial communication even while working on other tasks, as long as there room in the 64 byte serial buffer. The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality (hence the name “SoftwareSerial”). It is possible to have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for devices which require that protocol.

For information about the project Click Here.

Code
#include <SoftwareSerial.h>
SoftwareSerial screenserial(2, 3); // RX, TX

#include &lt;Servo.h&gt;
Servo myservo;
#define ta 0x86
#define tb 0x87
unsigned char ta_send[8]= {0xA5, 0x5A, 0x05, 0x82, 0x00, ta, 0x00, 0x00};
unsigned char tb_send[8]= {0xA5, 0x5A, 0x05, 0x82, 0x00, tb, 0x00, 0x00};
int x=0;
int y=0;
void setup()
{
  myservo.attach(9);
  Serial.begin(115200);
  screenserial.begin(115200);
  pinMode(5,OUTPUT);
}
void loop()
{
x=analogRead(A0);
y=map(x,0,1023,0,100);
x = map(x, 0, 1023, 180, 0);   
myservo.write(x); 

ta_send[6]=y/256;
ta_send[7]=y%256;
screenserial.write(ta_send,8);

tb_send[6]=x/256;
tb_send[7]=x%256;
screenserial.write(tb_send,8);

Serial.print("value :- ");
Serial.print(y);
Serial.println("----------");
delay(100);
}

For more information on Stone Technologies and how to form product Click Here.