Created
August 13, 2019 02:09
-
-
Save ArduinoDiscordBot/d8e978fa1220e004f6608c216d7c6292 to your computer and use it in GitHub Desktop.
Code by JellyPies#8181 - Tue Aug 13 2019 02:09:55 GMT+0000 (Coordinated Universal Time)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LCD Start | |
#include <LiquidCrystal.h> | |
const byte rs = 12, | |
en = 11, | |
d4 = 5, | |
d5 = 4, | |
d6 = 6, | |
d7 = 7; | |
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); | |
const byte screenWidth = 16; | |
const byte screenHeight = 2; | |
// LCD End | |
// Coin Accepter Start | |
float balance = 0; | |
int acceptorPin = 2; | |
// Coin Accepter End | |
void setup() { | |
// Runs 1x | |
Serial.begin(9600); | |
lcd.begin(screenWidth, screenHeight); | |
pinMode(acceptorPin, INPUT_PULLUP); | |
attachInterrupt(digitalPinToInterrupt(acceptorPin), addBalance, RISING); | |
initializeSystem(); | |
} | |
void loop() { | |
// Runs constantly | |
} | |
void addBalance() { | |
balance += 0.25; | |
lcd.clear(); | |
lcd.setCursor(0, 0); | |
lcd.print("Balance: $"); | |
lcd.print(balance); | |
if (balance >= 1.00) { | |
lcd.setCursor(0, 2); | |
lcd.print("Select Item"); | |
} | |
} | |
void initializeSystem() { | |
balance = 0; | |
lcd.clear(); | |
lcd.setCursor(0, 0); | |
lcd.print(" Welcome!"); | |
lcd.setCursor(0, 2); | |
lcd.print(" Insert Coins"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment