#include <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
// تعيين الاطراف
#define TFT_CS 15
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
// ///////////////////////////
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with default width and height
TFT_eSprite spr = TFT_eSprite(&tft); //تعريف رسم للطباعة بإسم spr
void setup()
{
tft.init(); // تجهيز الشاشة للطباعة
tft.setRotation(2); // اختيار اتجاه الطباعة عن طريق تغيير الرقم بين القوسين
tft.fillScreen(TFT_BLUE); // اختيار خلفية الشاشة باللون الأزرق
spr.createSprite(200, 285); // اختيار حجم الرسم المطبوع على الخلفية الزرقاء
}
int y = 0; // تعريف متغير بإسم y و قيمة 0
void loop(void)
{
spr.fillCircle(10,y,10,TFT_BLACK); // اضافة دائرة بالرسم بموقع 0و 10 و قطر 10 و اللون أسود
y = y +1; // اضافة 1 لموقع طباعة الدائرة الجديد باللون الأحمر بالرسم
spr.fillCircle(10,y,10,TFT_RED);// اضافة دائرة بالرسم بالموقع الجديد و 10 و قطر 10 و اللون أحمر
spr.drawString(String(y),20,230,7); // طباعة القيمة بالمتغير x بالموقع 20 و 240 و حجم خط 7
spr.pushSprite(10,10); // طباعة الرسم كامل على الشاشة بداية من الموقع 10 و10
if (y >230)
y =0;
}
include <LiquidCrystal.h> // for controlling the LCD display
#include <Tone.h> // for playing sounds
// Define LCD Pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Define Piezo speaker pin
Tone speaker(8);
// Define game variables
int level = 0; // 0 = Easy, 1 = Medium, 2 = Hard
int score = 0;
int timer = 0;
int posX = 0;
int posY = 0;
// Define game constants
const int MAX_SCORE = 100;
const int EASY_TIME = 30;
const int MEDIUM_TIME = 20;
const int HARD_TIME = 10;
const int MAX_X_POS = 15;
const int MAX_Y_POS = 1;
const int BEEP_FREQ
int buzzerPin = 7; // set pin number for buzzer
int melody[] = { 262, 196, 196, 220, 196, 0, 247, 262 }; // set the melody
int noteDuration[] = { 250, 250, 250, 250, 250, 250, 750, 750 }; // set the note duration
void setup() {
pinMode(buzzerPin, OUTPUT); // initialize the buzzer pin as an output
}
void loop() {
for (int i = 0; i < 8; i++) { // loop through the melody array
int noteDurationValue = 1000/noteDuration[i]; // calculate the duration of the current note
tone(buzzerPin, melody[i], noteDurationValue); // play the current note
delay(noteDurationValue