#include <LiquidCrystal.h>
LiquidCrystal lcd(12 ,11, 5, 4 , 3, 2);
const int switchPin=6;
const int SwitchPin=13;
int switchState=0;
int prevSwitchState=0;
int shopKey=0;
int reply;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
pinMode(switchPin,INPUT);
pinMode(SwitchPin,INPUT);
lcd.setCursor(0,0);
lcd.print("Welcome to");
lcd.setCursor(0,1);
lcd.print("Shop!");
}
void loop() {
// put your main code here, to run repeatedly
switchState=digitalRead(switchPin);
if (switchState==HIGH){
shopKey=shopKey+1;
}
if (shopKey==1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$- Sword2$ ");
lcd.setCursor(0,1);
lcd.print("Arrow1$ Bow2$ ");
}else if(shopKey==2){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$ Sword2$-");
lcd.setCursor(0,1);
lcd.print("Arrow1$ Bow2$ ");
}else if (shopKey==3){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$ Sword2$ ");
lcd.setCursor(0,1);
lcd.print("Arrow1$- Bow2$ ");
}else if (shopKey==4){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$ Sword2$ ");
lcd.setCursor(0,1);
lcd.print("Arrow1$ Bow2$-");
}else{
shopKey==1;
}
}
I made my arduino setup with the starter kit. My setup is the exact same as the setup from project 11 of the arduino starter kit except that i have added a button connected to pin 13 and replaced the motion sensor with another button(connected to pin 6 like the sensor). Whenever I push the button linked to pin 6, The interface doesn't change as intended. How can I solve this issue? (note: I am almost certain this is not a hardware problem. I tested the setup but with the code provided in the starter kit and it worked fine. If you doubt my claim I have attached a photo of my setup.)
#include <LiquidCrystal.h>
LiquidCrystal lcd(12 ,11, 5, 4 , 3, 2);
const int switchPin=6;
const int SwitchPin=13;
int switchState;
int prevSwitchState=0;
int shopKey=0;
int reply;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
pinMode(switchPin,INPUT);
pinMode(SwitchPin,INPUT);
lcd.setCursor(0,0);
lcd.print("Welcome to");
lcd.setCursor(0,1);
lcd.print("Shop!");
}
void loop() {
// put your main code here, to run repeatedly
switchState=digitalRead(6);
if (switchState==HIGH){
shopKey=shopKey+1;
}
if (shopKey==1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$- Sword2$ ");
lcd.setCursor(0,1);
lcd.print("Arrow1$ Bow2$ ");
}else if(shopKey==2){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$ Sword2$-");
lcd.setCursor(0,1);
lcd.print("Arrow1$ Bow2$ ");
}else if (shopKey==3){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$ Sword2$ ");
lcd.setCursor(0,1);
lcd.print("Arrow1$- Bow2$ ");
}else if (shopKey==4){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hat1$ Sword2$ ");
lcd.setCursor(0,1);
lcd.print("Arrow1$ Bow2$-");
}else{
shopKey=1;
}
}
This is how my code works like after the fix. Also I have a question. How can I upload files of a bigger size(I want to upload a picture, But the pictures file size is too big.)?