/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include <Servo.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
Servo Servo1;
#define TFT_DC 9
#define TFT_CS 10
int l1=0;
int l2=0;
int l3=0;
int l4=0;
int l5=0;
int l6=0;
int numar=0;
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(3,OUTPUT);
pinMode(2,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
pinMode(8,INPUT);
Servo1.attach(3);
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void Numaratoare()
{
if(digitalRead(2)==HIGH)
{
l1=1;
}
else
{
l1=0;
}
if(digitalRead(4)==HIGH)
{
l2=1;
}
else
{
l2=0;
}
if(digitalRead(5)==HIGH)
{
l3=1;
}
else
{
l3=0;
}
if(digitalRead(6)==HIGH)
{
l4=1;
}
else
{
l4=0;
}
if(digitalRead(7)==HIGH)
{
l5=1;
}
else
{
l5=0;
}
if(digitalRead(8)==HIGH)
{ l6=1;}
else
{ l6=0; }
numar=l1+l2+l3+l4+l5+l6;
}
void loop() {
if(digitalRead(A1)==HIGH|| digitalRead(A0)==HIGH)
{
Servo1.write(90);
delay(1000);
}
Numaratoare();
tft.begin();
tft.setCursor(30, 15);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Bine ati venit!");
tft.setCursor(30, 40);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Locuri libere:");
tft.setCursor(200, 40);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.fillRect(197,37,20,20,ILI9341_BLACK);
tft.println(numar);
//Locul1
tft.setCursor(2, 85);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#1");
tft.setCursor(30, 85);
if(l1==1)
{
tft.fillRect(30,85,70,20,ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("Ocupat");}
else
{
tft.fillRect(30,85,70,20,ILI9341_BLACK);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
}
//Locul6
if(l6==1)
{
tft.fillRect(130,85,70,20,ILI9341_BLACK);
tft.setCursor(130, 85);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("Ocupat");
}
else
{
tft.fillRect(130,85,70,20,ILI9341_BLACK);
tft.setCursor(130, 85);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
}
tft.setCursor(210,85);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#6");
//Locul2
tft.setCursor(2, 115);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#2");
if(l2==1)
{
tft.fillRect(30,115,70,20,ILI9341_BLACK);
tft.setCursor(30, 115);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("Ocupat");
}
else
{tft.fillRect(30,115,70,20,ILI9341_BLACK);
tft.setCursor(30, 115);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
}
//Locul7
if(l3==1)
{
tft.fillRect(130,115,70,20,ILI9341_BLACK);
tft.setCursor(130, 115);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("Ocupat");
}
else
{
tft.fillRect(130,115,70,20,ILI9341_BLACK);
tft.setCursor(130, 115);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
}
tft.setCursor(210, 115);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#7");
//Locul3
tft.setCursor(2, 145);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#3");
tft.setCursor(30, 145);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
//Locul8
tft.setCursor(130, 145);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
tft.setCursor(210, 145);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#8");
//Locul4
tft.setCursor(2,175);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#4");
tft.setCursor(30, 175);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
//Locul9
tft.setCursor(130, 175);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
tft.setCursor(210, 175);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#9");
//Locul5
tft.setCursor(2,205);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#5");
tft.setCursor(30, 205);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("Ocupat");
//Locul10
tft.setCursor(130, 205);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Liber");
tft.setCursor(200, 205);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("#10");
}