Hello all i just recently got into using a arduino and by recent i mean 2 days lol. Anyways I am making a automated can crusher and am having trouble finding a proper way to start my program using a button switch. Eventually when i am finished i will be using a proximity switch to activate to program/can crusher but until then i would like to use a simple button switch for testing. Sorry for the inconvenience any help or suggestions would be greatly appreciated! if it helps any here is my program i have came up with so far.
P.S sorry for the sloppy program its in the works. Just looking how to start it by simply pushing a button thanks again!
#include <LiquidCrystal.h> // library Code to use lcd display
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Pin #'s used on lcd display
#define RELAY1 7
#define RELAY2 8
void setup() {
lcd.begin(16,2);
lcd.setCursor(0, 2);
lcd.print("The Magic Tavern");
pinMode (RELAY1, OUTPUT); // lETTING PROGRAM KNOW THAT PINS ARE OUTPUTS FOR RELAY
delay (500); //cylinder #1 Extending
pinMode (RELAY2, OUTPUT);
digitalWrite (RELAY1,LOW);
delay(500); // Pause between cycle
digitalWrite(RELAY1,HIGH);
delay (7000); // Cylinder #2 Extending
digitalWrite(RELAY2,LOW);
delay(500);
digitalWrite(RELAY2,HIGH);
lcd.begin(16,2);
lcd.setCursor(0, 2);
lcd.print("The Magic Tavern");
lcd.begin(16, 1);
lcd.setCursor(0, 1);
lcd.print("GRAB ANOTHER COLD ONE");
delay(1000);
for (int positionCounter = 0; positionCounter < 8; positionCounter++) { // scrolls 17 positions (string length) to the left
lcd.scrollDisplayLeft();
delay(250);
}
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(250);
}
// delay at the end of the full loop:
lcd.noDisplay();
lcd.begin(16,2);
lcd.setCursor(0, 2);
lcd.print("The Magic Tavern");
}
void loop() { }