problem with percentage calculator

hello… any here can help me to check my code? i have problem with my code… i m just start program arduino several months ago… so im beginner…
i want to reduce output by% when output reach 130
i write the code but nothing happen…
not reduce the output
any hear can check it for me what i m wrong?
SORRY FOR MY ENGLISH

//////////////////////////////////////////////////////////////
// //
// SPI //
// Arduino nano Test 168/328p //
// //
//////////////////////////////////////////////////////////////
//wire library for SPI communication
#include <SPI.h>
//////////////////Begin library definitions section/////////////////
const int slaveSelectPin = 10;
int BoostPin = 0; // variable to store the sensor pin anlog1
int ScrB = 9; //Powertune value for voltage reduction
int sensorValue = 400; // variable to store the value coming from the sensor
void setup()
{
// set the slaveSelectPin as an output:
pinMode (slaveSelectPin, OUTPUT);
// initialize SPI:
SPI.begin();
Serial.begin(115200);
}
void loop()
{
float percent;
int DACval; // Store D/A value

sensorValue = analogRead(BoostPin); // read sensor value and store
DACval = (sensorValue / 4); // devide with 4 to make 0-1024 to 0-255 and add 2 for value alignment to 1020mbar

if(DACval > 130 ) // if more then 1300 mbar reduce dac value for scrambling
{
percent = (ScrB / 10) * (DACval);// percentage calculation
DACval = DACval - percent; // value reducer
}
digitalPotWrite(19, DACval);
}
void digitalPotWrite(int address, int value)
{
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin, LOW);
// send in the address and value via SPI:
SPI.transfer(address);
SPI.transfer(value);
// take the SS pin high to de-select the chip:
digitalWrite(slaveSelectPin, HIGH);
}

percent = (ScrB / 10) * (DACval);

ScrB is an integer value set to 9, so (ScrB / 10) is always equal to zero. Consequently, percent is always assigned the value zero.

try:

percent = DACval * ScrB / 10;

so how can i change this code to reduce 20 %... i m low knowledge in math..

arduinodlb: try:

percent = DACval * ScrB / 10;

not work still no reduce an output

As in this?

DACval = DACval * 8 / 10;

Get out a pocket calculator and start playing around with numbers.

9 / 10 = 0

9.0 / 10 = 0.9

uncle_inside:
not work still no reduce an output

Maybe DACval never exceeded 130.

AWOL:
9 / 10 = 0

9.0 / 10 = 0.9

thank friend…

i change ScrB=50… but output not go down its turn to high output in 3.5 volt out 4++volt… so how do i rotate this to make it go down?

I’m sorry, I don’t understand the question.
Can you post your code again (with code tags) with your observations, please?

Edit: Are you saying 50/10 gives the wrong results?

AWOL: I'm sorry, I don't understand the question. Can you post your code again (with code tags) with your observations, please?

Edit: Are you saying 50/10 gives the wrong results?

you gift me an idea.... problem solve...

one more question... how to post code inside something like you all post?

i post long code how to put inside

//////////////////////////////////////////////////////////////
//                                                          //
//                          SPI                             //
//              Arduino nano Test 168/328p                  //
//                                                          //
//////////////////////////////////////////////////////////////

//wire library for SPI communication
#include <SPI.h>
//////////////////Begin library definitions section/////////////////


const int slaveSelectPin = 10;
int BoostPin = 0;    // variable to store the sensor pin anlog1
int ScrB = 9; //Powertune value for voltage reduction
int sensorValue = 400;  // variable to store the value coming from the sensor

void setup()
{
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
  // initialize SPI:
  SPI.begin();
  Serial.begin(115200);
}

void loop()
{

  float percent;
  int DACval;                     // Store D/A value
  


  sensorValue = analogRead(BoostPin); // read sensor value and store
  DACval = (sensorValue / 4);  // devide with 4 to make 0-1024 to 0-255 and add 2 for value alignment to 1020mbar
 
  if(DACval > 130 )                   // if more then 1300 mbar reduce  dac value for scrambling
  {
    percent = (ScrB / 9.75) * (DACval /4);// percentage calculation
    DACval = DACval - percent;       // value reducer
  }
  digitalPotWrite(19, DACval);
}
void digitalPotWrite(int address, int value)
{
  // take the SS pin low to select the chip:
  digitalWrite(slaveSelectPin, LOW);
  //  send in the address and value via SPI:
  SPI.transfer(address);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin, HIGH);
}

You appear to be dividing the original reading by 16 - is that intentional?

thank to all who try to help me to solve my problem... now my code working nicely