Generator ON/OFF SOLVED
ted Thu Aug 09, 2018 8:36 am
This program has a generator and blinking LED.
How to modify it to get PWM signal on PB0 when the LED is ON and no signal when the LED is OFF ?
So far I have this error.
C:\Users\OWNER\AppData\Local\Temp\arduino_modified_sketch_892346\Blink.ino: In function ‘void loop()’:
Blink:34: error: lvalue required as left operand of assignment
if (PB1=1)
^
exit status 1
lvalue required as left operand of assignment
HardwareTimer pwmtimer3(3);
void setup() {
// pinMode(PA7, PWM);
pinMode(PB0, PWM);
pwmtimer3.pause();
pwmtimer3.setPrescaleFactor(400); // Timer input clock Prescaler = 1 (= 72MHz input ?)
pwmtimer3.setOverflow(100-1); // PWM Period width for 720kHz ?
pwmtimer3.setCompare(TIMER_CH3, 50); // PWM High Pulse width is 50% duty (1:1)
pwmtimer3.refresh();
pwmtimer3.resume();
// initialize digital pin PB1 as an output.
pinMode(PB1, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(PB1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(PB1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
if(PB1=HIGH) //error from this line
{
digitalWrite(PB0,PWM);
//LED = 1;
}
else
{
digitalWrite(PB0, LOW);
// LED = 0;
}
}
