ArduinoUNO+Nextion+Joystick+Moving Figure

2.0K46

Intro: ArduinoUNO+Nextion+Joystick+Moving Figure

Hi guys!

Today im going to describe my little-funny-evening project about moving the figure on the Nextion HMI display by the joystick connected to Arduino UNO :)

STEP 1: Components

1. Joystick

2. UNO board

3. Breadboard

4. Nextion HMI

See photos :)

STEP 2: Connections

1. Breadboard needed to share arduino power source among joystick and Nextion.

2. Joystick connection to Arduino:

5V -> 5V;

GND -> GND;

VRx -> A0;

VRy -> A1;

SW -> digital pin 2 (not important);

3. Nextion connection to Arduino:

5V -> 5V;

GND -> GND;

RX -> digital pin 4;

TX -> digital pin2;

Here you can find Instructable about uploading project to Nextion HMI.

STEP 3: Nextion Project

You need to create project in Nextion Editor and add 3 variables responsible for:

va0 - X-position of figure;

va1 - Y-position of figure;

va2 - in my project is the Raduis of circle;

Dont forget to set initial values!

STEP 4: Arduino Sketch

1. Please download and add this arduino library to work with Nextion HMI;

2. Upload my sketch;

3. Learn all used commands here;

STEP 5: Some Video....


Thank you:)

3 Comments

Hello. I couldn't find how to move this text left and right. What kind of variable should I assign?
Hi there,

This is really amazing, I have a few tiny questions.
1. Can the circle be replaced with a picture? eg sprite etc.
2. Is picture transparency supported?

Thanks !
Hi there.

Firstly, thank you for posting this code. I've been doing a lot of research into whether other people are asking the same question; how do you write code to control a shape on a HMI display using an Arduino and a joystick.

So, the problem I'm having is with your code.

When I install the Nextion library, all is good. When I compile the your code, I'm presented with the following error message:

'class Nextion' has no member named 'sendCommand'

I'm racking my brains out here, but this is code that taps into the Nextion library, but beyond that, I'm a bit lost.

I'm using an original Arduino Mega2560 board, so have changed the Rx pin accordingly as the one in your code is for the Uno.

I'm looking forward to seeing if you are able to help or point me in the right direction regarding my query.

Kind regards

Nigel