I am trying to make a stopwatch that prints a value when a button is pressed. What does this error code mean, and what do I need to change?
Here is the error:
Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Uno"
In file included from sketch\Stopwatch.ino.cpp:1:0:
C:\Users\Sam\Documents\Arduino\Stopwatch\Stopwatch.ino: In function 'void loop()':
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: lvalue required as left operand of assignment
#define HIGH 0x1
^
C:\Users\Sam\Documents\Arduino\Stopwatch\Stopwatch.ino:30:27: note: in expansion of macro 'HIGH'
if( digitalRead(11) = HIGH)
^~~~
exit status 1
Error compiling for board Arduino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Here is my code:
#include <Wire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup()
{
double t = 0;
lcd.begin(16,2);
lcd.clear();
lcd.print("Time: ");
pinMode(11, INPUT);
}
void loop()
{
double t = 0;
delay(2000);
for (double i = 0; i<=10.01 ; i=i+.01)
{
//lcd.print(i);
delay(10);
//lcd.clear();
t=i;
if( digitalRead(11) = HIGH)
{
i = 15;
}
}
lcd.print(t);
}
Note: It worked fine until I added the if statement to allow the button to stop it.