Loading...

You have no items in your shopping cart.

 
 
 
×

Registration

Profile Informations

Login Datas

or login

First name is required!
Last name is required!
First name is not valid!
Last name is not valid!
This is not an email address!
Email address is required!
This email is already registered!
Password is required!
Enter a valid password!
Please enter 6 or more characters!
Please enter 16 or less characters!
Passwords are not same!
Terms and Conditions are required!
Email or Password is wrong!
Captcha is required!
Captcha is wrong!

Product Preview: Nextion in an Arduino project (3)

In the previous blog, we demonstrate how to use Arduino to control a progress bar that shows on Nextion 2.4”. In that case, we use progress bar and text components in Nextion Editor. In this blog, we will tell you the other simple component – button. When you touch the area that is under the button component “monitor”, it will run the ID of this component, then you can realize some visual final effects like interface switching, sending data through serial port.

Hardware we use

  • Iteaduino UNO
  • Nextion 2.4"

Download the HMI file here: Touch_switch_Project

Code we use to Arduino UNO:

int char1,char2;
int charflag=0;

void setup() {
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop() {
 if (Serial.available()>1) 
{
 if (charflag)  
  {
  char2=Serial.read();
  if (char2==0) digitalWrite(13,HIGH);
  else if (char2==0x01) digitalWrite(13,LOW);
  charflag=0;
  }
  else
  {
   char1=Serial.read();
   if(char1==0x65) charflag=1;
  }
}
}