Hi
I am working on Wheatstone bridge, on the left side is a photoresistor , exposed to daylight, on right side is a photocoupler.
Brightness of the photo diode is regulated by 2 buttons to balance the bridge.
I want to replace 2 buttons by 1 button, when I press it the bridge should auto tune to minimum voltage of the bridge = currentValue.
This is what I did and error.
Can you help me ?
HardwareTimer pwmtimer4(4);// pulse duty =i
int i;
int ovfi;
int volt;
int Value;
int currentValue;
int previousValue;
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here
#include <LiquidCrystal.h>
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
void setup() {
//////////////////////
pwmtimer4.pause();
pwmtimer4.setPrescaleFactor(3);
pwmtimer4.setOverflow(2000);
//pwmtimer4.setCompare(TIMER_CH2, 2880);
pwmtimer4.refresh();
pwmtimer4.resume();
/////////////////////
pinMode(PB0, INPUT_ANALOG);
pinMode(PB9, INPUT_PULLDOWN);
lcd.begin(16, 2);
}
void loop()
{
float volt = analogRead(PB0);
volt = (volt * 3.3) / 4095.0;
ovfi = 3000 - i;
pwmtimer4.setCompare(TIMER_CH2, i); // PWM High Pulse width
/*
///////////////////////
if (digitalRead(PB9) == HIGH)
{
if (i < 3000)
{
i++;
}
}
if (digitalRead(PB6) == HIGH)
{
if (i > 0)
{
i–;
}
}
///////////////////////////
*/
previousValue = currentValue; // store what was read last time
currentValue = analogRead(PB0); // get a new reading
if (digitalRead(PB9) == HIGH)
{
//if (i < 3000)
if (previousValue > currentValue) = 1 // if = true = ++ , if false = –
{
i++;
}
else
{
i–;
}
///////////////////////////////
if (currentValue = minValue)
{
currentValue = minValue;
}
break; // stop changing "i" at minimum of currentValue
}
////////////////////////////////
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(volt);
lcd.setCursor(0, 1);
lcd.print( Value);
delay(100);
}
The error
tuning:59:39: error: expected primary-expression before ‘=’ token
if (previousValue > currentValue) = 1 // if = true = ++ , if false = --
^
tuning:73:5: error: break statement not within loop or switch
break;
^~~~~
exit status 1
expected primary-expression before ‘=’ token