hello everyone i got a problem, when ever i try to set the " ''' digitalWrite(buttonone, 1);
digitalWrite(buttontwo, 1); " ''' on 0 the screen gets sometimes glitched when you press a button which has the code in it my project consists of six buttons 4 are pushbuttons for apps and 2 are for menu scroll. also please suggest me a button menu scroll code. here is my code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#define buttonone 2
#define buttontwo 3
#define buttonthree 4
#define buttonfour 5
#define buttonfive 6
#define buttonsix 7
int state = 1;
void setup()
{
Serial.begin(9600);
pinMode(buttonone, INPUT_PULLUP);
pinMode(buttontwo, INPUT_PULLUP);
pinMode(buttonthree, INPUT_PULLUP);
pinMode(buttonfour, INPUT_PULLUP);
pinMode(buttonfive, INPUT_PULLUP);
pinMode(buttonsix, INPUT_PULLUP);
lcd.begin();
lcd.backlight();
lcd.setCursor ( 0, 0 );
lcd.print("grapics test");
lcd.setCursor(0,1);
lcd.print("hack!!>L.C.D.oi");
digitalWrite(buttonone, 1);
digitalWrite(buttontwo, 1);
digitalWrite(buttonthree, 1);
digitalWrite(buttonfour,1);
digitalWrite(buttonfive,1);
digitalWrite(buttonsix,1);
delay(200);
}
void loop()
{
state = digitalRead(buttonsix);
if (state != 1) { // menu 2
lcd.clear();
lcd.setCursor(0,0);
lcd.print("boot menu");
lcd.setCursor(0,1);
lcd.print("music player");
}
state = digitalRead(buttonone); // app 1
if (state != 1) {
lcd.clear();
lcd.print("under counstrucstion");
}
lcd.setCursor(0, 1);
state = digitalRead(buttontwo); // app 2
if (state != 1) {
lcd.clear();
lcd.print("under counstrucstion");
}
lcd.setCursor(0, 2);
state = digitalRead(buttonthree); // app 3
if (state != 1) {
lcd.clear();
lcd.print("under counstruction");
}
state = digitalRead(buttonfour); // app 4
if (state != 1) {
lcd.clear();
lcd.print("under counstruction");
}
state = digitalRead(buttonfive); //menu 1
if (state != 1) {
lcd.clear();
lcd.setCursor ( 0, 0 );
lcd.print("grapics test");
lcd.setCursor(0,1);
lcd.print("hack!!>L.C.D.oi");
}
}
```please help me as this is my first Arduino project
the problem is that the menu buttons have a code in which when you press menu 1 the app button 3 and 4 gets disabled and when i press that button it shows a glitchy text . actually the apps are written ' under construction ' so it shows that on my lcd
digital read button one to four are pushbutton when you press any of them they react
and digital read six and five are for menu
the thing is i want to put a command in which when you press digital read six it should disable digital read button 1 and 3 and when its digital read button five it should disable button 3 and 4
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
//********************************************^************************************************
#define PUSHED LOW
#define RELEASED HIGH
//********************************************^************************************************
const byte UP = 2;
const byte DOWN = 3;
const byte heartbeatLED = 13;
byte state;
byte lastUp = RELEASED;
byte lastDown = RELEASED;
int counter = 1;
//
char *menuText[] =
{
// Array element
"One", //0
"Two", //1
"Three", //2
"Four", //3
"Five", //4
"Six" //5
};
//timing stuff
unsigned long heartbeatMillis;
unsigned long switchMillis;
// s e t u p ( )
//********************************************^************************************************
void setup()
{
Serial.begin(9600);
pinMode(heartbeatLED, OUTPUT);
pinMode(UP, INPUT_PULLUP);
pinMode(DOWN, INPUT_PULLUP);
lcd.begin();
lcd.backlight();
lcd.setCursor ( 0, 0 );
lcd.print("Menu Number");
lcd.setCursor(0, 1);
lcd.print(menuText[counter - 1]);
} //END of setup()
// l o o p ( )
//********************************************^************************************************
void loop()
{
//********************************* heartbeat TIMER
//is it time to toggle the heartbeatLED ?
if (millis() - heartbeatMillis >= 500ul)
{
//restart this TIMER
heartbeatMillis = millis();
//toggle the heartbeatLED
digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
}
//********************************* switch TIMER
//is it time to check the switches ?
if (millis() - switchMillis >= 50ul)
{
//restart this TIMER
switchMillis = millis();
checkSwitches();
}
//*********************************
// Other none blocking code goes here
//*********************************
} //END of loop()
// c h e c k S w i t c h e s ( )
//********************************************^************************************************
void checkSwitches()
{
//******************************** UP switch
state = digitalRead(UP);
if (lastUp != state)
{
//update to the new state
lastUp = state;
//was the switch PUSHED ?
if (state == PUSHED)
{
//next menu
counter++;
//do not go past 6
if (counter > 6)
{
counter = 6;
}
lcd.clear();
lcd.print("Menu Number");
lcd.setCursor(0, 1);
lcd.print(menuText[counter - 1]);
}
}
//******************************** DOWN switch
state = digitalRead(DOWN);
if (lastDown != state)
{
//update to the new state
lastDown = state;
//was the switch PUSHED ?
if (state == PUSHED)
{
//next menu
counter--;
//do not go under 1
if (counter < 1)
{
counter = 1;
}
lcd.clear();
lcd.print("Menu Number");
lcd.setCursor(0, 1);
lcd.print(menuText[counter - 1]);
}
}
} //END of checkSwitches()
//********************************************^************************************************
sorry for the bad camera quality, anyways this is my computer thingy i have been working on
as you can see there are four buttons in the middle which are responsible for apps means when i press a button the lcd clears and shows the text
then i have 2 separate buttons the red one on the left side and the white one on the right side so those are responsible for menu <<>>> the white button is responsible for going back to the main menu and the red one is resposible for going to the second manu <<<<<>>>> now this is my main problem when ever i put the code in the menu buttons such as the white button i pu a code with says'''digitalWrite(buttonthree, 0);
digitalWrite(buttonfour,0);''' and when for the red one its opposite so when ever i press the menu buttons the lcd glitches and says the app text so i want to fix that
ok here is my code i am having difficulty with .What i want do is i want to make a code in which when you press a button the other buttons should disable its like padlock when you put a key in it you lock it and the padlock cannot be opened without a key same way it happens in my circuit the problem is when i put the code digitalwrite( buttonone , LOW);
digitalWrite(buttontwo , LOW);
then when i press that button which has the code in it the LCD goes haywire, its starts to show the app text and my entire projected becomes haywire only when i reset it it goes back to normal untill i press that button here is my code
All the buttons pins are intialzied as INPUT_PULL.
What is the desired goal by doing this?
Line 33: digitalWrite(buttonone, HIGH);
Line 34: digitalWrite(buttontwo, HIGH);
Line 35: digitalWrite(buttonthree, HIGH);
Line 36: digitalWrite(buttonfour, HIGH);
Line 37: digitalWrite(buttonfive, HIGH);
Line 38: digitalWrite(buttonsix, HIGH);
Line 47: digitalWrite(buttonone,LOW);
Line 48: digitalWrite(buttontwo,LOW);
Line 85: digitalWrite(buttonthree, LOW);
Line 86: digitalWrite(buttonfour, LOW);
Have a nice day and enjoy programming in C++ and learning.
i am planning to make an aurdino computer with six buttons also i had savage a tally counter and extracted its lcd so i will be using my aurdino to hack it by just using ground or some pins