#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int pinButton = 3;
const int pinLed = 7;
const int pinLed2 = 6;
const int pinLed3 = 5;
int b = 0;
int c = 0;
void setup()
{
lcd.begin(16, 2);
pinMode(pinButton, INPUT);
pinMode(pinLed, OUTPUT);
}
void loop()
{
if(digitalRead(pinButton))
{
c = b + 1;
if(c==1)
{
analogWrite(pinLed, HIGH);
}
if(c==2)
{
analogWrite(pinBuzz, HIGH);
}
else
{
lcd.setRGB(250,0,0);
lcd.print("ON");
analogWrite(pinLed3, HIGH);
}
}
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int pinButton = 3;
const int pinLed = 7;
const int pinLed2 = 6;
const int pinLed3 = 5;
int b = 0;
int c = 0;
void setup()
{
lcd.begin(16, 2);
pinMode(pinButton, INPUT);
pinMode(pinLed, OUTPUT);
}
void loop()
{
if(digitalRead(pinButton))
{
c = b + 1;
if(c==1)
{
analogWrite(pinLed, HIGH);
}
if(c==2)
{
analogWrite(pinBuzz, HIGH);
}
else
{
lcd.setRGB(250,0,0);
lcd.print("ON");
analogWrite(pinLed3, HIGH);
}
}
Can you help me with this code if you click the button once the LED will turn on and if you click twice the buzzer will turn on and if you click the button three time the LCD will print "ON" this could be the code?
You can only have one setup() and loop() function in your program. Get rid of one and see what happens.