Need help with timer project
i'm learning , i'm having trouble code , getting error message (exit status 1
lvalue required left operand of assignment). i'm trying create system when start_button pushed, turns on greenled amount of time goes , turns off greenled , turns on yellowled. redled. kind of stop light can't use delay because have 2 more buttons need monitor. i'm not going add other buttons until part of code working. appreciated.
lvalue required left operand of assignment). i'm trying create system when start_button pushed, turns on greenled amount of time goes , turns off greenled , turns on yellowled. redled. kind of stop light can't use delay because have 2 more buttons need monitor. i'm not going add other buttons until part of code working. appreciated.
code: [select]
const int ledpin = 3; // number of led pin
// variables change:
int ledstate = low; // ledstate used set led
long previousmillis = 0; // store last time led updated
boolean start_state = false; // start button status set false until button pressed
// following variables long because time, measured in miliseconds,
// become bigger number can stored in int.
long interval_1 = 300; // interval between green , yellow led}
long interval_2 = 300; // inteval between yellow , red led)
#define greenled 2
#define yellowled 3
#define redled 4
#define start_button 8
#define emergency_button 9
//#define open_button 10 ***this switch unused****
void setup() {
// set digital pin output:
pinmode(greenled, output);
pinmode(yellowled, output);
pinmode(redled, output);
pinmode(start_button, input);//input start button
pinmode(emergency_button, input);//input emergency button
}
void loop()
{
// check see if it's time blink led; is, if
// difference between current time , last time blinked
// led bigger interval @ want
// blink led.
digitalwrite(redled = low)
unsigned long currentmillis = millis();
{
if (digitalread(start_button) == high)//if start button pressed
{
start_state = true;
if (start_state == high);
digitalwrite(greenled = high);
}
if(currentmillis - previousmillis > interval_1) {
// save last time blinked led
previousmillis = currentmillis;
{
digitalwrite(greenled = low);
digitalwrite(yellowled = high);
}
if(currentmillis - previousmillis > interval_2) {
// save last time blinked led
previousmillis = currentmillis;
digitalwrite(yellowled = low);
digitalwrite(redled = high);
}
}
shouldcode: [select]digitalwrite(greenled = high);
code: [select]
digitalwrite(greenled, high);
and other digitalwrite() calls need same change.
please read https://www.arduino.cc/en/reference/digitalwrite
Arduino Forum > Using Arduino > Programming Questions > Need help with timer project
arduino
Comments
Post a Comment