CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC16F877A Two segment display
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Khansokhua



Joined: 06 Nov 2021
Posts: 88

View user's profile Send private message

PostPosted: Sun Nov 14, 2021 5:34 am     Reply with quote

Code:
#include <ROBOT.h>
int i;
const int yazi[5]={0xAF,0x23,0x03,0x23,0x07};  // r,o,b,o,t
  //   7 Segment Two Digits LED Display Common Anode
  //     1  0101111=r                                       
  //   (dp) gfedcba        zero bit  makes on led
  //     1  0100011=o   
  //     1  0000011=b
  //     1  0000111=t
// d0 top middle 'a' segment
// d1 top right 'b'
// d2 bottom right 'c'
// d3 bottom middle 'd'
// d4 bottom left 'e'
// d5 top left 'f'
// d6 middle 'g'
#use delay (clock=4000000)



void main()
{
     output_low(pin_a2); //  left digit off   onlar
     output_low(pin_a3); //  right digit off  birler
   
    while(TRUE)
   {     
           output_high(pin_a3);
           output_d(yazi[0]);
           delay_ms(400);
   
         for(i=0;i<51;i++)
         {
         
           
             
             output_high(pin_a2);
             output_d(yazi[1]);
             delay_ms(5);
             output_low(pin_a2);
             output_high(pin_a3);
             output_d(yazi[2]);
             delay_ms(5);
             output_low(pin_a3);                                               
         
         }
     
        for(i=0;i<51;i++)
         {
         
           
             
             output_high(pin_a2);
             output_d(yazi[2]);
             delay_ms(5);
             output_low(pin_a2);
             output_high(pin_a3);
             output_d(yazi[3]);
             delay_ms(5);
             output_low(pin_a3);                                               
         
         }
     
          for(i=0;i<51;i++)
         {
         
           
             
             output_high(pin_a2);
             output_d(yazi[3]);
             delay_ms(5);
             output_low(pin_a2);
             output_high(pin_a3);
             output_d(yazi[4]);
             delay_ms(5);
             output_low(pin_a3);                                               
         
         }
         
          for(i=0;i<51;i++)
         {
         
           
             
             output_high(pin_a2);
             output_d(yazi[4]);
             delay_ms(5);
             output_low(pin_a2);
             output_high(pin_a3);
             output_d(0xFF);
             delay_ms(5);
             output_low(pin_a3);                                               
         
         }
         
           output_low(pin_a2); //  left digit off   onlar
           output_low(pin_a3); //  right digit off  birler
           
           delay_ms(400);
           
           
   }

}


This was what I wanted to do. Thank you for encouraging me. Respects
PrinceNai



Joined: 31 Oct 2016
Posts: 452
Location: Montenegro

View user's profile Send private message

PostPosted: Sun Nov 14, 2021 8:09 am     Reply with quote

Great, glad you made it work. I'd just change the first and last pattern to work as all the rest (meaning 5ms on, 5ms off) to achieve the same brightness.
Khansokhua



Joined: 06 Nov 2021
Posts: 88

View user's profile Send private message

PostPosted: Sun Nov 14, 2021 9:16 am     Reply with quote

PrinceNai wrote:
Great, glad you made it work. I'd just change the first and last pattern to work as all the rest (meaning 5ms on, 5ms off) to achieve the same brightness.

Thank you
temtronic



Joined: 01 Jul 2010
Posts: 9101
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 14, 2021 10:05 am     Reply with quote

In future programs, you should use the #DEFINE feature of the compiler to put 'names' to the PIN_XN designations.
It'll really help us and you 'see' what a pin is supposed to do.
Say PIN_D0 is connected to the 7 segment display 'a' pin:
Code:
#DEFINE 7SD_A PIN_D0; //seven segment 'a'

As well as 'saying' what it does, if you need to change the pin from say D0 to B3, you just change the define, NOT every D0 in the program. Saves a LOT of retyping and possible mistakes.
Khansokhua



Joined: 06 Nov 2021
Posts: 88

View user's profile Send private message

PostPosted: Sun Nov 14, 2021 4:16 pm     Reply with quote

temtronic wrote:
In future programs, you should use the #DEFINE feature of the compiler to put 'names' to the PIN_XN designations.
It'll really help us and you 'see' what a pin is supposed to do.
Say PIN_D0 is connected to the 7 segment display 'a' pin:
#DEFINE 7SD_A PIN_D0; //seven segment 'a'
As well as 'saying' what it does, if you need to change the pin from say D0 to B3, you just change the define NOT every D0 in the program. Saves a LOT of retyping and possible mistakes.

Thank you. I hope I will use useful.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group