News:

Let's find out together what makes a PIC Tick!

Main Menu

Need Help Nextion VU Meter w/ Proton Basic

Started by FWoro, Oct 12, 2025, 05:54 AM

Previous topic - Next topic

FWoro

Can anyone here give me an idea to create a Nextion VU Meter w/Proton Basic.

FWoro

Frizie

#1
Copy underneath code to your Positron program:


DIM VU_Meter   AS BYTE        ;The value from this BYTE (max. 100!) is send to the Nextion VU-meter

DO
  FOR VU_Meter = 100 DOWNTO 0 ;Steers a value from 100% to 0% to the VU-meter
    HMIval("j1", VU_Meter)    ;Send the 'VU_Meter' value to VU-meter 'j1' from Nextion
    DELAYMS 20                ;Take it easy...
  NEXT
LOOP                          ;Do it forever


;Procedure to send a BIT, BYTE or WORD value to a Nextion HMI
PROC HMIval(HMI_Component AS STRING * 20, HMI_Value AS WORD)
  HSEROUT [HMI_Component, ".val=", DEC HMI_Value, 0xFF, 0xFF, 0xFF]
ENDPROC


I assume that you have connected the Nextion to the hardware RX/TX port of the PIC and that you already have this working.
Ohm sweet Ohm | www.picbasic.nl

FWoro

Quote from: Frizie on Oct 12, 2025, 04:00 PMCopy underneath code to your Positron program:


DIM VU_Meter   AS BYTE        ;The value from this BYTE (max. 100!) is send to the Nextion VU-meter

DO
  FOR VU_Meter = 100 DOWNTO 0 ;Steers a value from 100% to 0% to the VU-meter
      HMIval("j1", VU_Meter)    ;Send the 'VU_Meter' value to VU-meter 'j1' from Nextion
      DELAYMS 20                ;Take it easy...
  NEXT
LOOP                          ;Do it forever


;Procedure to send a BIT, BYTE or WORD value to a Nextion HMI
PROC HMIval(HMI_Component AS STRING * 20, HMI_Value AS WORD)
  HSEROUT [HMI_Component, ".val", DEC HMI_Value, 0xFF, 0xFF, 0xFF]
ENDPROC


I assume that you have connected the Nextion to the hardware RX/TX port of the PIC and that you already have this working.

Frizie,
Well it's good starting to me, will try it once I home.

FWoro

Fanie

#3
I don't know what a Nextion VU Meter is, according to google images it is any meter ?

If so, then you can use a PWM peripheral and drive the meter with that.
The output is a suitable resistor and cap (for smoothing) to drive the meter and output is 0 to 100% (Same as D/A).
The advantage is the PWM peripheral free the pic to do other code while the PWM continuously drive the meter.

See the HPWM command in the 8-bit help manual.  The 16F684 for instance has 4 PWM channels and you can drive 4 such meters.

Stephen Moss

Quote from: Fanie on Oct 13, 2025, 11:15 AMI don't know what a Nextion VU Meter is, according to google images it is any meter ?
I beleive Nextion is just a make of graphic display and the OP was asking for code that uses one to display a representation of VU, which is usually used in Audio equipment like mixing desks.