Switch Rotary with LCD and LED

Hello everyone, i want to ask about my project. I use 1 Switch Rotary with 3 positions, 3 LED’s and 1 LCD. When i add “Ground” for pin 1 (LED and Switch Rotary) it can be works but the LCD can’t be show the text.

If i’m not add “Ground” for pin 1, the LCD can be show the text but LED and Switch Rotary can’t be work. (The LCD show the text with 3 conditions “Channel 1”, “Channel 2”, and “Channel 3” without controlled by Switch Rotary)

My goal : When i push the Switch Rotary in my desire, the LED can be light and the LCD can be show the text under controlled by Switch Rotary.

Here my project code :

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int switchPin = 1;
int Display = 0;

void setup()
{
lcd.begin(16, 1);
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH);
}

void loop()
{
if (digitalRead(switchPin) == HIGH){
delay(200);

Display ++;
if(Display > 4){
lcd.clear();
Display = 1;
}

switch (Display) {
case 1: {
lcd.setCursor(0, 0);
lcd.print(“Channel 1”);

break;
}

case 2: {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Channel 2”);
break;
}

case 3: {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Channel 3”);
break;
}

}
}
}

How is the 3 position switch wired ?
A circuit diagram, even a hand drawn one, would help

When the “Ground” not add in Pin 1. (CTSSS 1.png)
When the “Ground” add in Pin 1. (CTSSS.png)

this is completely wrong
not ground pin 1 of arduino.
not use pin 1 of arduino for led (if you connect also to PC).

led is wired :
from "digital pin x" ;resistor 470 ohm; +led; -led; ground; when want to turn ON with "high" or
from "digital pin x" ;resistor 470 ohm; -led; +led; VCC; when want to turn ON with "low"

connect gnd of arduino to gnd of lcd and any other gnd of circuit

good luck

demkat1:
this is completely wrong
not ground pin 1 of arduino.
not use pin 1 of arduino for led (if you connect also to PC).

led is wired :
from "digital pin x" ;resistor 470 ohm; +led; -led; ground; when want to turn ON with "high" or
from "digital pin x" ;resistor 470 ohm; -led; +led; VCC; when want to turn ON with "low"

connect gnd of arduino to gnd of lcd and any other gnd of circuit

good luck

Okay thank you for your correction. So, how i can connected the LCD text with the Switch Rotary ? I'm confused with my project now :frowning:

take a look at tutorials for lcd (for example "hello world") and for connecting switches, leds etc to arduino.

take a look at examples (ide, file/examples/basics/DigitalReadSerial)

rintosw:
So, how i can connected the LCD text with the Switch Rotary ?

Examine the diagram below:

Wire your LEDs to separate Arduino pins, configured as outputs (not pins 0,1 !).

Wire each selector switch (SS) terminal to its own Arduino pin configured as input. If you configure them as INPUT_PULLUP then no external resistor is needed - S3 on the diagram. Wire the common of the SS to ground. If using external pullup wire as S2. You can also wire the inputs as S1* using *pulldown *resistors. In all cases each switch need its own pull up/down resistor.

Use the state of the inputs, combined with other code, to control the LEDs and control which message is printed to the LCD.

demkat1:
take a look at tutorials for lcd (for example "hello world") and for connecting switches, leds etc to arduino.

take a look at examples (ide, file/examples/basics/DigitalReadSerial)

Okay, i will to try it, thank you.

dougp:
Examine the diagram below:

Wire your LEDs to separate Arduino pins, configured as outputs (not pins 0,1 !).

Wire each selector switch (SS) terminal to its own Arduino pin configured as input. If you configure them as INPUT_PULLUP then no external resistor is needed - S3 on the diagram. Wire the common of the SS to ground. If using external pullup wire as S2. You can also wire the inputs as S3 using *pulldown *resistors. In all cases each switch need its own pull up/down resistor.

Use the state of the inputs, combined with other code, to control the LEDs and control which message is printed to the LCD.

Thank you, i will to try it now :slight_smile: