







السمعة:
- إنضم26 يونيو 2023
- المشاركات 1,713
- الحلول 31
- مستوى التفاعل 2,969
- النقاط 113
فكرة المشروع بكل اختصار عرض التاريخ على LCD و تحريك المؤشر لليمين و اليسار من خلال زرين و زيادة و تقليل الرقم (الحرف) على الشاشة من خلال زرين أيضا
بالإضافة لوجود بعض المحددات لكي لا يزيد اليوم عن 31 و الشهر عن 12 و ان يكون هناك حدود لحركة المؤشر و ان لا يتمكن من تحديد ال /الكود المستعمل
ملاحظة : قم بتحليل الكود لمعرفة التوصيلات بشكل دقيق
بالإضافة لوجود بعض المحددات لكي لا يزيد اليوم عن 31 و الشهر عن 12 و ان يكون هناك حدود لحركة المؤشر و ان لا يتمكن من تحديد ال /الكود المستعمل
ملاحظة : قم بتحليل الكود لمعرفة التوصيلات بشكل دقيق
C++:
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define sw1 6 // move right
#define sw2 7 // move left
#define sw3 8 // value high
#define sw4 9 // value low
char date[]="00/00/0000";
int count=0;
void setup() {
pinMode(sw1, INPUT_PULLUP);
pinMode(sw2, INPUT_PULLUP);
pinMode(sw3, INPUT_PULLUP);
pinMode(sw4, INPUT_PULLUP);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.print(" The Date Is: ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.print(date);
}
void loop() {
if (digitalRead(sw1)==LOW)
{
while(digitalRead(sw1)==LOW)
;
count++;
if (count == 2 || count == 5) count++; // تخطي الشرطة المائلة
if (count > 9 || count < 0) count =0;
lcd.setCursor(count, 1);
delay(200);
}
if (digitalRead(sw2)==LOW)
{
while(digitalRead(sw1)==LOW)
;
count--;
if (count == 2 || count == 5) count--; // تخطي الشرطة المائلة
if (count > 9 || count < 0) count =0;
lcd.setCursor(count, 1);
delay(200);
}
if (digitalRead(sw3)==LOW)
{
while(digitalRead(sw3)==LOW)
;
date[count]++;
if (date[count]>'9')date[count]='9';
if (date[0]>'2')date[0]='3';
if (date[3]>'1')date[3]='1';
if (date[0]=='3' && date[1]>'0')date[1]='1';
if (date[3]=='1' && date[4]>'2')date[4]='2';
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(date);
delay (50);
}
if (digitalRead(sw4)==LOW)
{
while(digitalRead(sw3)==LOW)
;
date[count]--;
if (date[count]<'0')date[count]='0';
if (date[0]<'0')date[0]='0';
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(date);
delay (50);
}
}