led level meter code help please

hi could you please help me with my work project code the idea of the hardware is so on the back of a work machine it visual display of angle of machine with leds i have the code working so it lights one led on each direction of angle but cant seem to figure out how to light all the leds in the direction of travel so if it center 1 led is lit but if it is angle left at 90 degrees all the leds in that direction would be lit here is my code thanks for looking

#include "Tlc5940.h"
#include <math.h>
#define M_PI 3.1415926535897932
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(43, 39, 35, 33, 31, 29);

int pinsy[] = {
  1,2,3,4,5,6,7,8,9,10,11,12,13,14,17,18,19,20,21};

int pinsx[] = {
 22,23,24,25,26,27,28,29,30,33,34,35,36,37,38,39,40,41,42};
  
const int yledCount = 19;    // the number of LEDs in the bar graph
const int xledCount = 19;    // the number of LEDs in the bar graph
  
  
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

int xPin = 0;
int yPin = 1;
int selPin = 42;
int sleepPin = 44;

float xValue, yValue, zValue;
float gxValue, gyValue, gzValue;
float degxValue, degyValue, degzValue;;
const float scalePoints = 1023/5;

float calValues[4] = {0,0};
int numReadings = 0;
int maxNumReadings = 20;
long dt = 250;
long lastTime = 0;


void setup() {
  Serial.begin(9600);
  digitalWrite(sleepPin,HIGH);
  analogReference(EXTERNAL); 
  getCalValues();
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // loop over the pin array and set them all to output:
  // set up the LCD's number of columns and rows: 
    Tlc.init();
}

void loop() {
  

  xValue = analogRead(xPin);
  yValue = analogRead(yPin);
  
  gxValue = constrain((xValue/scalePoints-1.65-calValues[0])/0.8,-1,1);
  gyValue = constrain((yValue/scalePoints-1.65-calValues[1])/0.8,-1,1);
  
  degxValue = asin(gxValue)/M_PI*180;
  degyValue = asin(gyValue)/M_PI*180;

  Serial.print(degxValue,1); Serial.print("   "); lcd.setCursor(2,0); lcd.print( "U + D = "); lcd.print(degxValue,0 ); lcd.print(" Deg ");
  Serial.print(degyValue,1); Serial.print("   "); lcd.setCursor(2,2); lcd.print( "L + R = "); lcd.print(degyValue,0 ); lcd.print(" Deg ");
  Serial.println("\t"); Serial.println("\t");  
    
  
 
  int xbar1 = map(degxValue, -90, 90, 0, 19);
  int xbar = constrain(xbar1, 0, 19);
  for (int channel = xbar; channel < xbar+1; channel++) {
  Tlc.set(pinsy[channel], 4095);

  int ybar1 = map(degyValue, -90, 90, 0, 19); 
  int ybar = constrain(ybar1, 0, 19);
  for (int channel = ybar; channel < ybar+1; channel++) {
  Tlc.set(pinsx[channel], 4095);
  {
     Tlc.update();
     Tlc.clear();
     delay(950);
     break;}
      }
    }
  }

void getCalValues() {
  while (numReadings < maxNumReadings)
    if (millis() - lastTime > dt) {
      calValues[0] = calValues[0] + analogRead(xPin);
      calValues[1] = calValues[1] + analogRead(yPin);
      lastTime = millis();
      numReadings++;
  }
  calValues[0] = (calValues[0] / maxNumReadings)/scalePoints-1.65;
  calValues[1] = (calValues[1] / maxNumReadings)/scalePoints-1.65;
}

hi could you please help me with my work project code the idea of the hardware is so on the back of a work machine it visual display of angle of machine with leds i have the code working so it lights one led on each direction of angle but cant seem to figure out how to light all the leds in the direction of travel so if it center 1 led is lit but if it is angle left at 90 degrees all the leds in that direction would be lit here is my code thanks for looking

Perhaps you could modify your previous post, and add a few of these .....................................

Some capital letters and other punctuation would be useful, too.

  Serial.begin(9600);

After using one of the serial pins for an LED? I don't think so.

i am new to arduino and autistic sorry about bad punctuation i thought this was a forum i could get help with my project not punctuation lessons

You can only get help if people can understand your problem. I have had several goes at reading what you wrote and I can't understand what you are trying to do.

this is what it does now at 10 degree increments each led lights up with the angle of direction like these pics





what i need it to do is keep the following leds to stay lit as the angle of direction changes and it lights up the led like this





thanks for looking at this for me

I'd suggest that you put each { on a new line, as well as each }. Then, use Tools + Auto Format to format your code correctly.

Next, perhaps you can explain some things:

  for (int channel = ybar; channel < ybar+1; channel++)
  {
     Tlc.set(pinsx[channel], 4095);
     {
        Tlc.update();
        Tlc.clear();
        delay(950);
        break;
     }
  }

Why are there curly braces after the Tlc.set() call and after the break statement? Why are you looping, and then breaking out of the loop on the first pass? Even without the break, explain exactly how many times that loop will execute. Then, explain why you need a loop that iterates once.

thanks for help i cleaned up code got some things in wrong places

thanks for your help

Tlc.clear();

  int xbar1 = map(degxValue, -90, 90, 0, 19);
  int xbar = constrain(xbar1, 0, 19);
  for (int channel = min(xbar,10); channel <= max(xbar,10); channel++) {
    Tlc.set(pinsy[channel], 4095);
  }
  int ybar1 = map(degyValue, -90, 90, 0, 19);
  int ybar = constrain(ybar1, 0, 19);
  for (int channel = min(ybar,10); channel < max(ybar,10); channel++) {
    Tlc.set(pinsx[channel], 4095);
  }
  Tlc.update();
  delay(950);

So to achieve what you want you have to light all the LEDs up to the one giving you the angle indication.
So you need to have the target LED in a variable, that is the LED that defines your angle on the display.

Then have a loop ( a for loop ) that goes through all the LEDs and only light an LED if the current loop index is less than or equal to the target LED. To do this use an if() statement inside the loop.

There are other ways of doing it but that is the simplest to describe.