View previous topic :: View next topic |
Author |
Message |
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
|
Posted: Sun Nov 14, 2021 5:34 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 507 Location: Montenegro
|
|
Posted: Sun Nov 14, 2021 8:09 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
|
Posted: Sun Nov 14, 2021 9:16 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9377 Location: Greensville,Ontario
|
|
Posted: Sun Nov 14, 2021 10:05 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
|
Posted: Sun Nov 14, 2021 4:16 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|