I was testing my RGB (common anode) on its own playing with colours and got the red, green to work as desired.

However, when I connected my LCD board to my Arduino Uno as well as the RGB (using the same code prior and same output pins so I know the code isn't the issue) the RGB no longer displays red.

I assume it has something to do with the fluctuating voltage/current after I've put in the LCD but I cant work out how to resolve it. When its meant to be red it's just nothing, doesn't light up, green however still works.

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int SelectCounter = 0;
int hours = 0; // start hours
int minutes = 0; //start min
int seconds = 5; //start seconds
int redPin = A1;
int greenPin = 2;
int bluePin = 3;
int digitposition = 0;
int readkey;
int speaker = A5;
int buttonPin = A4;
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0; 

void setup() {
pinMode(speaker, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT); 
pinMode(buttonPin, INPUT);

void loop() {
setColor(0, 0, 255); // red

....... }

void trigger() {
  lcd.clear(); // clears the screen and buffer
 lcd.println("MUM:      ");
 lcd.setCursor(4, 1); // set timer position on lcd for end.
 lcd.println("WAKE UP!    ");
 tone(speaker, 10);
 setColor(0, 255, 0);  // green
 digitalWrite(A1, HIGH);
 digitalWrite(2, HIGH);
 digitalWrite(3, HIGH);

void setColor(int red, int green, int blue)
   red = 255 - red;
   green = 255 - green;
   blue = 255 - blue;
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
  • Without schematics and the code it's impossible to answer. However many libraries affects timers and all pwm channels on it. But I don't see why the LCD library should be using a timer.
    – KIIV
    Mar 15, 2018 at 8:16
  • Would what I've added suffice?
    – Angus Ryan
    Mar 15, 2018 at 8:21
  • pin 1 is TX of Serial
    – Juraj
    Mar 15, 2018 at 8:33
  • 3
    @AngusRyan and now it works or not? In any case, I suggest you to read the analogwrite arduino page. Particularly the part when they say "On most Arduino boards (those with the ATmega168 or ATmega328P), this function works on pins 3, 5, 6, 9, 10, and 11" and "You do not need to call pinMode() to set the pin as an output before calling analogWrite()"
    – frarugi87
    Mar 15, 2018 at 9:17
  • 5
    The analogWrite works on PWM pins only.
    – KIIV
    Mar 15, 2018 at 9:17

1 Answer 1


Only the pins with a ~ next to it are PWM pins. The pin connected to the red led, pin A1, does not support PWM, so analogWrite will not have the desired effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.