Skip to content

Instantly share code, notes, and snippets.

@erdemarslan
Last active July 27, 2018 11:45
Show Gist options
  • Select an option

  • Save erdemarslan/ad53242be10dc79e9bb070f24a8aab41 to your computer and use it in GitHub Desktop.

Select an option

Save erdemarslan/ad53242be10dc79e9bb070f24a8aab41 to your computer and use it in GitHub Desktop.
Limonata Makinesi Test 1
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16,2);
const byte coinPin = 2;
const byte buttonPin = 3;
const byte motorPin = 6;
volatile double lira = 0.00;
volatile int paraGeldimi = 0;
volatile int suAksin = 0;
void setup()
{
pinMode(buttonPin, INPUT);
pinMode(motorPin, OUTPUT);
lcd.init();
//attachInterrupt(digitalPinToInterrupt(buttonPin), buttonPressed, RISING);
attachInterrupt(digitalPinToInterrupt(coinPin), coinInserted, RISING);
lcd.backlight();
lcd.clear();
lcd.home();
lcd.print("Bakiye: 0 TL");
lcd.setCursor(0,1);
lcd.print("Motor: Durdu");
}
void coinInserted() {
if(paraGeldimi == 0) {
lira = lira + 0.25;
paraGeldimi = 1;
}
}
/*
void buttonPressed() {
if(suAksin == 0) {
suAksin = 1;
}
}
*/
void loop()
{
if(digitalRead(buttonPin) == HIGH) {
lcd.setCursor(7,1);
lcd.print(" ");
lcd.setCursor(7,1);
lcd.print("Calisiyor");
analogWrite(motorPin, 255);
delay(1000);
analogWrite(motorPin, 0);
lcd.setCursor(7,1);
lcd.print(" ");
lcd.setCursor(7,1);
lcd.print("Durdu");
suAksin = 0;
}
if(paraGeldimi == 1) {
lcd.setCursor(8,0);
lcd.print(" ");
lcd.setCursor(8,0);
String veri = String(lira) + " TL";
lcd.print(veri);
paraGeldimi = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment