2-Laboratoriya ishi Mavzu: ta yetti segmentli indikatorlardan tashkil topgan razryadli matritsa. Dinamik aks ettirishni amalga oshirish (Arduinoda) Laboratoriya ishining maqsadi
Download 197.76 Kb. Pdf ko'rish
|
12-laboratoriya ishi
- Bu sahifa navigatsiya:
- Ulanish tartibi
8.2 listingi
// a – g razryadlariga ulanish uchun Arduino oyoqchalarining rо‘yxati // yetti segmentli nidikatorni intpins[8]={9,13,4.6,7,10,3,5}; // 0-9 raqamlarni chiqarish uchun qiymatlar byte numbers[10] = { B11111100, V01100000, B11011010, B11110010, B01100110, B10110110, B10111110, B11100000, B11111110, B11110110}; // hozirdagi qiymatni ishlov berish va saqlash uchun о‘zgaruvchi int number=0; int numberl=0; int number2=0; // yetti segmentli indikatorni intpindigits[4]={2,8,ll,12}; // hozirdagi razryadni saqlash uchun о‘zgaruvchi intdigit=0; // о‘lchash uchun 100 ms unsignedlongmillisl=0; // ish tartib 1 – soniya hisoblagich ishlamoqda mode=0; constintBUTTON=14; // 14(AO) ulanish nuqta tugmani ulash uchun inttekButton = LOW; // Tugmani hozirdagi holatini saqlash uchun о‘zgaruvchi intprevButton = LOW; // Tugmani oldingi holatini saqlash uchun // tugmani booleanledOn = false; // Yorug‘lik diodini hozirdagi holati (yoqiq/о‘chiq) voidsetup() { // tugmaning ulanish nuqtasiini kirish kabi о‘zgartirish pinMode (BUTTON, INPUT); // ulanish nuqtalarini chiqishlar kabi о‘zgartirish for(int i=0;i<8;i++) pinMode(pins[i],OUTPUT); for(int i=0;i<4;i++) {pinMode(pindigits[i],OUTPUT); digitalWrite(pindigits[1],HIGH); } } void loop() { tekButton = debounce(prevButton); if (prevButton == LOW && tekButton == HIGH) // agarda bosilish... { mode=l-mode; // ish tartibini о‘zgartirish if(mode==l) number=0; } if(millis()-millisl>=100 && mode==l) { millis1= millis1+100; number=number+l; if (nurnber==10000) number=0; } numberl=nuraber; for(int i=0;i<4;i++) { number2=numberH10; numberl=numberl/10; showNumber(number2,i); for(int j=0;j<4;j++) digitalWrite(pindigits[j],HIGH); digitalWrite(pindigits[i],LOW); delay(1); } } // yetti segmentli inldikatorga sonlarni chiqarish funksiyasi void showNuraber(int num,int dig) { for(int i=0;i<8;i++) { if(bitRead(numbers[num],7-i)==HIGH) // segmentni yoqish digitalWrite(pins[i],HIGH); else // potushit segment digitalWrite(pins[i],LOW); } if(dig==l) // ikkinchi razryad uchun о‘nlik nuqta digitalWrite(pins[7],HIGH); } // Titrashni yо‘q qilish funksiyasi. Tugmani oldingi holatini argument sifatida qabul qiladi // va xaqiyqiysini beradi, boolean debounce(boolean last) { boolean current = digitalRead(BUTTON); // Tugma holatini sanash, if (last != current)// agarda о‘zgarsa... { delay(5);// jdem 5 ms current = digitalRead(BUTTON);// tugma holati о‘qiladi returncurrent; // tugma holati qaytariladi } } Ulanish tartibi: 1. 8.3 chizmada kо‘rsatilganidek yetti segmentli indikator ulanadi. 2. 8.2 listingdagi sketchni Arduino platasiga yuklanadi. 8.3-chizma. Soniya hisoblagichi uchun ulanish sxemasi. 3. Tugma bosilishi bilan soniya hisoblagichini ishga tushiriladi yoki tо‘xtatiladi. Download 197.76 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling