منتديات الهندسة الكهربية والإلكترونية والميكاترونكس والكومبيوتر
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

التدريب الثانى : إنشاء عداد بمفتاح ضاعط أو بحساس لعد الأشياء من “0” إلى “99” باستخدم وحدتى عرض سفن سيجمنت مع المترجم CCS C .

اذهب الى الأسفل

التدريب الثانى : إنشاء عداد بمفتاح ضاعط أو بحساس لعد الأشياء من “0” إلى “99” باستخدم وحدتى عرض سفن سيجمنت مع المترجم CCS C  .   Empty التدريب الثانى : إنشاء عداد بمفتاح ضاعط أو بحساس لعد الأشياء من “0” إلى “99” باستخدم وحدتى عرض سفن سيجمنت مع المترجم CCS C .

مُساهمة من طرف Admin الأربعاء مايو 06, 2015 4:47 pm

التدريب الثانى : إنشاء عداد بمفتاح ضاعط أو بحساس لعد الأشياء من “0” إلى “99” باستخدم وحدتى عرض سفن سيجمنت مع المترجم CCS C .

التدريب الثانى : إنشاء عداد بمفتاح ضاعط أو بحساس لعد الأشياء من “0” إلى “99” باستخدم وحدتى عرض سفن سيجمنت مع المترجم CCS C  .   225

البرنامج :

الكود:

/******************************************************
 Application : Button , Objects up counter 0-99 , 7-segment 2-units Display without transistors 
 *******************************************************/
#include <16f877.h>    //
#use delay(clock=4000000)  // Gecikme fonksiyonu için kullan‎lan osilatِr frekans‎ belirtiliyor

#define  display_1  pin_a0      //display unit-1 comm-catode , from lift i.e. for Tens
#define  display_2  pin_a1      // display unit-2 comm-catode , for Units
#define  buton      pin_a2      // use button as pin_a2

char units=0, tens=0, count=0;      // declare char variables

// 10 Data values for common cathode display 0,1,2....9
const int digit[10]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7C, 0x07, 0x7F, 0x6F};

/********* main program********/

void main ()
{
 
  output_high(display_1);      // initially disable display unit-1 , high , and ...
  output_high(display_2);      // initially disable display unit-2 , high

  while(true)
  {
      ////////////////////calculations ///////////////////
        units=count%10;  // get units digit by Calculating the remainder of cout/10
        tens=count/10;  // get ten digit by calculated count/10
      ////////////////////Display Units ////////////////////////
        output_low(display_2);  // enable display uint-2  ,units on 
        output_b(digit[units]); // send display data information , units
        delay_ms(5);            // small delay
        output_high(display_2);  // disable display uint-2 , units off
        /////////////////////////Display Tens////////////////////////
      output_low(display_1);  // enable display uint-1 , tens on
        output_b(digit[tens]);  // send display data information
        delay_ms(5);            // small delay
      output_high(display_1);  // disable display uint-1 , tens off
      ////////////////////////test button //////////////////////////////////
     
        if (input(buton))  // If The count up button is pressed >>>>
        {
            delay_ms(10);  // 1- button debounce

            count++;        // 2- counter variable increases by 1
        ////////////////////special cases /////////////////////
            if (count==100)  // and if count reach 100 , then rest it
              count=0;      //reset count variable
        ///////////////////////and >>>>>>>>>>//////////////////////////
            while(input(buton))  // Processing cycle until the button is released , no increasing
            {
              output_low(display_2);  // enable unit
              output_b(digit[units]); // display unuts
              delay_ms(5);            // small delay
              output_high(display_2);  // disable units
           
              output_low(display_1);  // enable tens
              output_b(digit[tens]);  // display tens
              delay_ms(5);            // small delay
              output_high(display_1);  // disable tens
            }
        }
  }
}


Admin
Admin

عدد المساهمات : 1194
تاريخ التسجيل : 28/01/2014

https://fathallaabdelaziz.forumarabia.com

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة


 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى