Here i have a project i am under going, i am very new to Arduino code and arduinos in general.
i have 7 slide switches and i want each to display a different bit of text for example switch1 displays "Hello" and then clears once the switch is flicked back to normal.
and if switch 2 is flicked it will display a complete different message and so on.
Any help is appreciated.
I suggest you use the LCD example to get your LCD working as its wired into the circuit.
Then add in button press detection. Once you can display messages to the LCD and detect buttons then the next is to code for a detected button press to display a thingy.
Include IDE - file/examples/digital/statechangedetection in your reading. You'll want to detect when a switch goes closed rather than when it is closed.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int SwitchSlide1 = 13;
const int LCD = 7;
int switchState1 = 0;
void setup() {
pinMode(LCD, OUTPUT); //initialize the led pin as output
lcd.begin(16 ,2);
}
void loop(){
//read the state of the switch value
switchState1 = digitalRead(SwitchSlide1);
}
if (switchState1 == HIGH}{
lcd.clear();
lcd.setCursor(0, 0)
lcd.print("vmtA")
{
You did not configure the pinMode for the switch in setup(). I would recommend configuring the internal pull-up so you do not need a resistor. This means that use should use GND when the switch is activated and therefore ON=LOW and OFF=HIGH
Your switch wiring does not make sense. You realize the center terminal on the switch is common? The way you have it wired if you move the switch to the right you will short GND to 5V!!!
You need to detect when the switch state changes and account for debounce. See the following tutorial: StateChangeDetection