قسم الميكروكنترولر والروبوت ودوائر الاتصال بالحاسب الالي قسم المتحكمات الـ microcontroller و المعالجات microprocessor و التحكم الرقمي بالكمبيوتر CNC والانظمة الآلية والروبوت Robots

أدوات الموضوع

بوغنيم
:: مهندس ::
تاريخ التسجيل: Apr 2015
المشاركات: 29
نشاط [ بوغنيم ]
قوة السمعة:0
قديم 07-03-2016, 11:45 AM المشاركة 1   
افتراضي طلب مساعدة Twitter FaceBook Google+



عندي مشروع أخواني فيه مشكل في شاشة lcd لا تخرج شي !
هل من مساعدة أخواني

كود:
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections



unsigned short read_ds1307(unsigned short address)
{
  unsigned short r_data;
  I2C1_Start();
  I2C1_Wr(0xD0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
  I2C1_Wr(address);
  I2C1_Repeated_Start();
  I2C1_Wr(0xD1); //0x68 followed by 1 --> 0xD1
  r_data=I2C1_Rd(0);
  I2C1_Stop();
  return(r_data);
}


void write_ds1307(unsigned short address,unsigned short w_data)
{
  I2C1_Start(); // issue I2C start signal
  //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
  I2C1_Wr(0xD0); // send byte via I2C (device address + W)
  I2C1_Wr(address); // send byte (address of DS1307 location)
  I2C1_Wr(w_data); // send data (data to be written)
  I2C1_Stop(); // issue I2C stop signal
}


unsigned char BCD2UpperCh(unsigned char bcd)
{
  return ((bcd >> 4) + '0');
}


unsigned char BCD2LowerCh(unsigned char bcd)
{
  return ((bcd & 0x0F) + '0');
}


int Binary2BCD(int a)
{
   int t1, t2;
   t1 = a%10;
   t1 = t1 & 0x0F;
   a = a/10;
   t2 = a%10;
   t2 = 0x0F & t2;
   t2 = t2 << 4;
   t2 = 0xF0 & t2;
   t1 = t1 | t2;
   return t1;
}


int BCD2Binary(int a)
{
   int r,t;
   t = a & 0x0F;
   r = t;
   a = 0xF0 & a;
   t = a >> 4;
   t = 0x0F & t;
   r = t*10 + r;
   return r;
}



int second;
int minute;
int hour;
int hr;
int day;
int dday;
int month;
int year;
int ap;




unsigned short set_count = 0;
short set;

char time[] = "00:00:00 PM";
char date[] = "00-00-00";









void main()
{
   I2C1_Init(100000); //DS1307 I2C is running at 100KHz

   CMCON = 0x07;   // To turn off comparators
   //ADCON1 = 0x06;  // To turn off analog to digital converters

   ADCON1 = 0x00 ;                         // set PORTA as analog input
   TRISA = 0xff ;                          // set PORTA as inputs
   OPTION_REG = 0x80 ;                     // start timer 0, no prescaler
   INTCON = 0xA0 ;                         // allow timer 0 overflow interrupt

   //TRISA = 0x07;
   //PORTA = 0x00;

   TRISD = 0x0F;
   PORTD = 0x00;
   Lcd_Init();                        // Initialize LCD
   Lcd_Cmd(_LCD_CLEAR);               // Clear display
   Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off


   do
   {
     if (Button(&PORTD, 0, 1, 0))
     {

          if (Button(&PORTD, 0, 1, 0))
         {
             set_count++;
             if(set_count >= 7)
             {
                set_count = 0;
             }
         }
     }
     if(set_count)
     {
         if (Button(&PORTD, 1, 1, 0))
        {

           if (Button(&PORTD, 1, 1, 0))
              set = 1;
        }

         if (Button(&PORTD, 2, 1, 0))
        {

           if (Button(&PORTD, 2, 1, 0))
              set = -1;
        }
        if(set_count && set)
        {
          switch(set_count)
          {
            case 1:
                    hour = BCD2Binary(hour);
                    hour = hour + set;
                    hour = Binary2BCD(hour);
                    if((hour & 0x1F) >= 0x13)
                    {
                      hour = hour & 0b11100001;
                      hour = hour ^ 0x20;
                    }
                    else if((hour & 0x1F) <= 0x00)
                    {
                      hour = hour | 0b00010010;
                      hour = hour ^ 0x20;
                    }
                    write_ds1307(2, hour); //write hour
                    break;
            case 2:
                     minute = BCD2Binary(minute);
                     minute = minute + set;
                     if(minute >= 60)
                        minute = 0;
                     if(minute < 0)
                        minute = 59;
                     minute = Binary2BCD(minute);
                     write_ds1307(1, minute); //write min
                     break;
            case 3:
                    if(abs(set))
                      write_ds1307(0,0x00); //Reset second to 0 sec. and start Oscillator
                    break;
            case 4:
                     day = BCD2Binary(day);
                     day = day + set;
                     day = Binary2BCD(day);
                     if(day >= 0x32)
                        day = 1;
                     if(day <= 0)
                        day = 0x31;
                     write_ds1307(4, day); // write date 17
                     break;
            case 5:
                    month = BCD2Binary(month);
                    month = month + set;
                    month = Binary2BCD(month);
                    if(month > 0x12)
                      month = 1;
                    if(month <= 0)
                      month = 0x12;
                    write_ds1307(5,month); // write month 6 June
                    break;
            case 6:
                    year = BCD2Binary(year);
                    year = year + set;
                    year = Binary2BCD(year);
                    if(year <= -1)
                       year = 0x99;
                    if(year >= 0x50)
                       year = 0;
                    write_ds1307(6, year); // write year
                    break;
          }
        }
     }

      second = read_ds1307(0);
      minute = read_ds1307(1);
      hour = read_ds1307(2);
       hr = hour & 0b00011111;
       ap = hour & 0b00100000;
      dday = read_ds1307(3);
      day = read_ds1307(4);
      month = read_ds1307(5);
      year = read_ds1307(6);


      time[0] = BCD2UpperCh(hr);
      time[1] = BCD2LowerCh(hr);
      time[3] = BCD2UpperCh(minute);
      time[4] = BCD2LowerCh(minute);
      time[6] = BCD2UpperCh(second);
      time[7] = BCD2LowerCh(second);

      date[0] = BCD2UpperCh(day);
      date[1] = BCD2LowerCh(day);
      date[3] = BCD2UpperCh(month);
      date[4] = BCD2LowerCh(month);
      date[6] = BCD2UpperCh(year);
      date[7] = BCD2LowerCh(year);

      if(ap)
      {
         time[9] = 'P';
         time[10] = 'M';
      }
      else
      {
         time[9] = 'A';
         time[10] = 'M';
      }


      Lcd_out(1, 1, time);
      Lcd_out(2, 1, date);

      Delay_ms(100);


   }while(1);
}

[IMG][/IMG]

اعلانات

الصورة الرمزية gheas
gheas
:: مهندس متواجد ::
تاريخ التسجيل: May 2005
الدولة: https://t.me/pump_upp
المشاركات: 128
نشاط [ gheas ]
قوة السمعة:0
قديم 07-03-2016, 01:08 PM المشاركة 2   
افتراضي


عندي مشروع أخواني فيه مشكل في شاشة lcd لا تخرج شي !
هل من مساعدة أخواني

كود:
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections



unsigned short read_ds1307(unsigned short address)
{
  unsigned short r_data;
  I2C1_Start();
  I2C1_Wr(0xD0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
  I2C1_Wr(address);
  I2C1_Repeated_Start();
  I2C1_Wr(0xD1); //0x68 followed by 1 --> 0xD1
  r_data=I2C1_Rd(0);
  I2C1_Stop();
  return(r_data);
}


void write_ds1307(unsigned short address,unsigned short w_data)
{
  I2C1_Start(); // issue I2C start signal
  //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
  I2C1_Wr(0xD0); // send byte via I2C (device address + W)
  I2C1_Wr(address); // send byte (address of DS1307 location)
  I2C1_Wr(w_data); // send data (data to be written)
  I2C1_Stop(); // issue I2C stop signal
}


unsigned char BCD2UpperCh(unsigned char bcd)
{
  return ((bcd >> 4) + '0');
}


unsigned char BCD2LowerCh(unsigned char bcd)
{
  return ((bcd & 0x0F) + '0');
}


int Binary2BCD(int a)
{
   int t1, t2;
   t1 = a%10;
   t1 = t1 & 0x0F;
   a = a/10;
   t2 = a%10;
   t2 = 0x0F & t2;
   t2 = t2 << 4;
   t2 = 0xF0 & t2;
   t1 = t1 | t2;
   return t1;
}


int BCD2Binary(int a)
{
   int r,t;
   t = a & 0x0F;
   r = t;
   a = 0xF0 & a;
   t = a >> 4;
   t = 0x0F & t;
   r = t*10 + r;
   return r;
}



int second;
int minute;
int hour;
int hr;
int day;
int dday;
int month;
int year;
int ap;




unsigned short set_count = 0;
short set;

char time[] = "00:00:00 PM";
char date[] = "00-00-00";









void main()
{
   I2C1_Init(100000); //DS1307 I2C is running at 100KHz

   CMCON = 0x07;   // To turn off comparators
   //ADCON1 = 0x06;  // To turn off analog to digital converters

   ADCON1 = 0x00 ;                         // set PORTA as analog input
   TRISA = 0xff ;                          // set PORTA as inputs
   OPTION_REG = 0x80 ;                     // start timer 0, no prescaler
   INTCON = 0xA0 ;                         // allow timer 0 overflow interrupt

   //TRISA = 0x07;
   //PORTA = 0x00;

   TRISD = 0x0F;
   PORTD = 0x00;
   Lcd_Init();                        // Initialize LCD
   Lcd_Cmd(_LCD_CLEAR);               // Clear display
   Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off


   do
   {
     if (Button(&PORTD, 0, 1, 0))
     {

          if (Button(&PORTD, 0, 1, 0))
         {
             set_count++;
             if(set_count >= 7)
             {
                set_count = 0;
             }
         }
     }
     if(set_count)
     {
         if (Button(&PORTD, 1, 1, 0))
        {

           if (Button(&PORTD, 1, 1, 0))
              set = 1;
        }

         if (Button(&PORTD, 2, 1, 0))
        {

           if (Button(&PORTD, 2, 1, 0))
              set = -1;
        }
        if(set_count && set)
        {
          switch(set_count)
          {
            case 1:
                    hour = BCD2Binary(hour);
                    hour = hour + set;
                    hour = Binary2BCD(hour);
                    if((hour & 0x1F) >= 0x13)
                    {
                      hour = hour & 0b11100001;
                      hour = hour ^ 0x20;
                    }
                    else if((hour & 0x1F) <= 0x00)
                    {
                      hour = hour | 0b00010010;
                      hour = hour ^ 0x20;
                    }
                    write_ds1307(2, hour); //write hour
                    break;
            case 2:
                     minute = BCD2Binary(minute);
                     minute = minute + set;
                     if(minute >= 60)
                        minute = 0;
                     if(minute < 0)
                        minute = 59;
                     minute = Binary2BCD(minute);
                     write_ds1307(1, minute); //write min
                     break;
            case 3:
                    if(abs(set))
                      write_ds1307(0,0x00); //Reset second to 0 sec. and start Oscillator
                    break;
            case 4:
                     day = BCD2Binary(day);
                     day = day + set;
                     day = Binary2BCD(day);
                     if(day >= 0x32)
                        day = 1;
                     if(day <= 0)
                        day = 0x31;
                     write_ds1307(4, day); // write date 17
                     break;
            case 5:
                    month = BCD2Binary(month);
                    month = month + set;
                    month = Binary2BCD(month);
                    if(month > 0x12)
                      month = 1;
                    if(month <= 0)
                      month = 0x12;
                    write_ds1307(5,month); // write month 6 June
                    break;
            case 6:
                    year = BCD2Binary(year);
                    year = year + set;
                    year = Binary2BCD(year);
                    if(year <= -1)
                       year = 0x99;
                    if(year >= 0x50)
                       year = 0;
                    write_ds1307(6, year); // write year
                    break;
          }
        }
     }

      second = read_ds1307(0);
      minute = read_ds1307(1);
      hour = read_ds1307(2);
       hr = hour & 0b00011111;
       ap = hour & 0b00100000;
      dday = read_ds1307(3);
      day = read_ds1307(4);
      month = read_ds1307(5);
      year = read_ds1307(6);


      time[0] = BCD2UpperCh(hr);
      time[1] = BCD2LowerCh(hr);
      time[3] = BCD2UpperCh(minute);
      time[4] = BCD2LowerCh(minute);
      time[6] = BCD2UpperCh(second);
      time[7] = BCD2LowerCh(second);

      date[0] = BCD2UpperCh(day);
      date[1] = BCD2LowerCh(day);
      date[3] = BCD2UpperCh(month);
      date[4] = BCD2LowerCh(month);
      date[6] = BCD2UpperCh(year);
      date[7] = BCD2LowerCh(year);

      if(ap)
      {
         time[9] = 'P';
         time[10] = 'M';
      }
      else
      {
         time[9] = 'A';
         time[10] = 'M';
      }


      Lcd_out(1, 1, time);
      Lcd_out(2, 1, date);

      Delay_ms(100);


   }while(1);
}

[IMG][/IMG]
السلام عليكم ورحمة الله
اخي قم بوصل RW لشاشة LCD بالارض (GND)
وستعمل الشاشة


التعديل الأخير تم بواسطة : gheas بتاريخ 07-03-2016 الساعة 01:16 PM
اعلانات اضافية ( قم بتسجيل الدخول لاخفائها )
  

بوغنيم
:: مهندس ::
تاريخ التسجيل: Apr 2015
المشاركات: 29
نشاط [ بوغنيم ]
قوة السمعة:0
قديم 08-03-2016, 07:08 AM المشاركة 3   
افتراضي


بارك الله فيك أخي

تحل المشكل الشاشة
الآن مشكل على ما أظن في برنامج لانه لا يخرج قيمة الحرارة في شاشة ما عاد التوقيت و حرف T:
كود:
              // LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
unsigned long ADRead;
unsigned int vDisp[3];
unsigned char Display[7];
unsigned short read_ds1307(unsigned short address)
{
  unsigned short r_data;
  I2C1_Start();
  I2C1_Wr(0xD0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
  I2C1_Wr(address);
  I2C1_Repeated_Start();
  I2C1_Wr(0xD1); //0x68 followed by 1 --> 0xD1
  r_data=I2C1_Rd(0);
  I2C1_Stop();
  return(r_data);
}


void write_ds1307(unsigned short address,unsigned short w_data)
{
  I2C1_Start(); // issue I2C start signal
  //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
  I2C1_Wr(0xD0); // send byte via I2C (device address + W)
  I2C1_Wr(address); // send byte (address of DS1307 location)
  I2C1_Wr(w_data); // send data (data to be written)
  I2C1_Stop(); // issue I2C stop signal
}


unsigned char BCD2UpperCh(unsigned char bcd)
{
  return ((bcd >> 4) + '0');
}


unsigned char BCD2LowerCh(unsigned char bcd)
{
  return ((bcd & 0x0F) + '0');
}


int Binary2BCD(int a)
{
   int t1, t2;
   t1 = a%10;
   t1 = t1 & 0x0F;
   a = a/10;
   t2 = a%10;
   t2 = 0x0F & t2;
   t2 = t2 << 4;
   t2 = 0xF0 & t2;
   t1 = t1 | t2;
   return t1;
}


int BCD2Binary(int a)
{
   int r,t;
   t = a & 0x0F;
   r = t;
   a = 0xF0 & a;
   t = a >> 4;
   t = 0x0F & t;
   r = t*10 + r;
   return r;
}



int second;
int minute;
int hour;
int hr;
int day;
int dday;
int month;
int year;
int ap;




unsigned short set_count = 0;
short set;

char time[] = "00:00:00 PM";
char date[] = "00-00-00";
void main()
{
   I2C1_Init(100000); //DS1307 I2C is running at 100KHz

   CMCON = 0x07;   // To turn off comparators
   //ADCON1 = 0x06;  // To turn off analog to digital converters

   ADCON1 = 0x0E ;                         // set PORTA as analog input
  // TRISA = 0xff ;                          // set PORTA as inputs
   OPTION_REG = 0x80 ;                     // start timer 0, no prescaler
   INTCON = 0xA0 ;                         // allow timer 0 overflow interrupt

   TRISA = 0x01;
   PORTA= 0;
   PORTB=0;
   TRISB=0;
   TRISD = 0x0F;
   PORTD = 0x00;
   Lcd_Init();                        // Initialize LCD
   Lcd_Cmd(_LCD_CLEAR);               // Clear display
   Lcd_Cmd(_LCD_CURSOR_OFF);         // Cursor off
    LCD_Out(2, 10,"T:" );
    //Display = "+125 'C";
     Display[4] = 39; //'
     Display[5]= 'C';
     ADCON1 = 0x0E;
     ADC_Init();

   do
   {
     if (Button(&PORTD, 0, 1, 0))
     {

          if (Button(&PORTD, 0, 1, 0))
         {
             set_count++;
             if(set_count >= 7)
             {
                set_count = 0;
             }
         }
     }
     if(set_count)
     {
         if (Button(&PORTD, 1, 1, 0))
        {

           if (Button(&PORTD, 1, 1, 0))
              set = 1;
        }

         if (Button(&PORTD, 2, 1, 0))
        {

           if (Button(&PORTD, 2, 1, 0))
              set = -1;
        }
        if(set_count && set)
        {
          switch(set_count)
          {
            case 1:
                    hour = BCD2Binary(hour);
                    hour = hour + set;
                    hour = Binary2BCD(hour);
                    if((hour & 0x1F) >= 0x13)
                    {
                      hour = hour & 0b11100001;
                      hour = hour ^ 0x20;
                    }
                    else if((hour & 0x1F) <= 0x00)
                    {
                      hour = hour | 0b00010010;
                      hour = hour ^ 0x20;
                    }
                    write_ds1307(2, hour); //write hour
                    break;
            case 2:
                     minute = BCD2Binary(minute);
                     minute = minute + set;
                     if(minute >= 60)
                        minute = 0;
                     if(minute < 0)
                        minute = 59;
                     minute = Binary2BCD(minute);
                     write_ds1307(1, minute); //write min
                     break;
            case 3:
                    if(abs(set))
                      write_ds1307(0,0x00); //Reset second to 0 sec. and start Oscillator
                    break;
            case 4:
                     day = BCD2Binary(day);
                     day = day + set;
                     day = Binary2BCD(day);
                     if(day >= 0x32)
                        day = 1;
                     if(day <= 0)
                        day = 0x31;
                     write_ds1307(4, day); // write date 17
                     break;
            case 5:
                    month = BCD2Binary(month);
                    month = month + set;
                    month = Binary2BCD(month);
                    if(month > 0x12)
                      month = 1;
                    if(month <= 0)
                      month = 0x12;
                    write_ds1307(5,month); // write month 6 June
                    break;
            case 6:
                    year = BCD2Binary(year);
                    year = year + set;
                    year = Binary2BCD(year);
                    if(year <= -1)
                       year = 0x99;
                    if(year >= 0x50)
                       year = 0;
                    write_ds1307(6, year); // write year
                    break;
          }
        }
     }

      second = read_ds1307(0);
      minute = read_ds1307(1);
      hour = read_ds1307(2);
       hr = hour & 0b00011111;
       ap = hour & 0b00100000;
      dday = read_ds1307(3);
      day = read_ds1307(4);
      month = read_ds1307(5);
      year = read_ds1307(6);


      time[0] = BCD2UpperCh(hr);
      time[1] = BCD2LowerCh(hr);
      time[3] = BCD2UpperCh(minute);
      time[4] = BCD2LowerCh(minute);
      time[6] = BCD2UpperCh(second);
      time[7] = BCD2LowerCh(second);

      date[0] = BCD2UpperCh(day);
      date[1] = BCD2LowerCh(day);
      date[3] = BCD2UpperCh(month);
      date[4] = BCD2LowerCh(month);
      date[6] = BCD2UpperCh(year);
      date[7] = BCD2LowerCh(year);
     if(ap)
      {
         time[9] = 'P';
         time[10] = 'M';
      }
      else
      {
         time[9] = 'A';
         time[10] = 'M';
      }


      Lcd_out(1, 1, time);
      Lcd_out(2, 1, date);
      
      Delay_ms(100);
}       while(1);
   ADRead = (ADC_Get_Sample(0) * 500) >> 10;
           vDisp[0] = ADRead / 100;
           vDisp[1] = (ADRead / 10) % 10;
           vDisp[2] = ADRead % 10;
           Display[1] = vDisp[0] + 48;
           Display[2] = vDisp[1] + 48;
           Display[3] = vDisp[2] + 48;
           LCD_Chr(2, 8, Display[0]);
           LCD_Chr(2, 9, Display[1]);
           LCD_Chr(2, 10, Display[2]);
           LCD_Chr(2, 11, Display[3]);
           LCD_Chr(2, 12, Display[4]);
           LCD_Chr(2, 13, Display[5]);
           //LCD_Out(2, 8, ); // 'Show temperature
           delay_ms(200); //200ms delay for waiting
}
[IMG][/IMG]


الصورة الرمزية عبدالله حجازى
عبدالله حجازى
:: عضو ذهبي ::
تاريخ التسجيل: Apr 2011
الدولة: مصر .. محافظة دمياط
المشاركات: 1,688
نشاط [ عبدالله حجازى ]
قوة السمعة:110
قديم 08-03-2016, 05:06 PM المشاركة 4   
افتراضي اللهم انفعنا بما علمتنا وعلمنا ما ينفعنا وزدنا علما


السلام عليكم ورحمه الله


اخى الكريم دة مشروع لقياس الحرارة بفاصل الدرجة المشروع من تنفيذ .. Eng.F.Abdelaziz


كود:
 
/*
Digital Thermometer using PIC16F877A and LM35
Oscillator * 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF
Eng.F.Abdelaziz
http://www.eeecb.com/vb/index.php
*/
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
// Define Messages
char message0[] = "LCD Initialized";
char message1[] = "Room Temperature";
// String array to store temperature value to display
char *tempC = "000.0";
// Variables to store temperature values
unsigned int tempinC;
unsigned long temp_value;
void Display_Temperature( ) {
 // convert Temp to characters
     if (tempinC/10000)
// 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/10000  + 48;
     else tempC[0] = ' ';
     tempC[1] = (tempinC/1000)%10 + 48;        // Extract tens digit
     tempC[2] =  (tempinC/100)%10 + 48;          // Extract ones digit
// convert temp_fraction to characters
   tempC[4] =  (tempinC/10)%10 + 48;        // Extract tens digit
// print temperature on LCD
 Lcd_Out(2, 1, tempC);
 }
void main() {
ADCON1 = 0b00000001;   // Connect AN3 , select Vref=1.2V
TRISD = 0b00000000;   // PORTD All Outputs
TRISA = 0xFF;    // PORTA All Inputs
 Lcd_Init();                          // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR);               // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF);           // Cursor off
 Lcd_Out(1,1,message0);
 Delay_ms(1000);
Lcd_Out(1,1,message1);               // Write message1 in 1st row
 // Print degree character
  Lcd_Chr(2,6,223);
  // Different LCD displays have different char code for degree symbol
 // if you see greek alpha letter try typing 178 instead of 223
   Lcd_Chr(2,7,'C');
 
while(1) {
  temp_value = ADC_Read(0);
  temp_value = temp_value*1168;
  tempinC = temp_value/100;
  Display_Temperature();
  Delay_ms(1000);    // Temperature sampling at 1 sec interval
               
               
} 
}

بالتوفيق

احصائية الشكر والاعجاب - 1 شكراً, 0 عدم اعجاب, 1 اعجاب
شكراً gheas ( شكر العضو على هذه المشاركة )
اعجاب gheas ( أعجبته المشاركة )

بوغنيم
:: مهندس ::
تاريخ التسجيل: Apr 2015
المشاركات: 29
نشاط [ بوغنيم ]
قوة السمعة:0
قديم 09-03-2016, 02:23 PM المشاركة 5   
افتراضي


بارك الله فيكم أخواني و جزاكم الله خيرا

إضافة رد

العلامات المرجعية

«     الموضوع السابق       الموضوع التالي    »
أدوات الموضوع

الانتقال السريع إلى


الساعة معتمدة بتوقيت جرينتش +3 الساعة الآن: 10:44 PM
موقع القرية الالكترونية غير مسؤول عن أي اتفاق تجاري أو تعاوني بين الأعضاء
فعلى كل شخص تحمل مسئولية نفسه إتجاه مايقوم به من بيع وشراء وإتفاق وأعطاء معلومات موقعه
التعليقات المنشورة لا تعبر عن رأي موقع القرية الالكترونية ولايتحمل الموقع أي مسؤولية قانونية حيال ذلك (ويتحمل كاتبها مسؤولية النشر)

Powered by vBulletin® Version 3.8.6, Copyright ©2000 - 2025