HELP ME PLS.. C PROGRAMMING
Discussion in "8051 Discussion Forum" started by xx1mar Dec 15, 2007.
Sat Dec 15 2007, 10:44 pm
hello,
im newbie in c programming, kindly help me with this program.. Im using a DS89c450 microcontroller and three 7-seven segment display with port 1, 2 and port 3 as my output.. im making a text message using a 7-segment.. this program was too long and i want to add some more characters.. what is the syntax to shorten this program.. Thank you
this is my program
im newbie in c programming, kindly help me with this program.. Im using a DS89c450 microcontroller and three 7-seven segment display with port 1, 2 and port 3 as my output.. im making a text message using a 7-segment.. this program was too long and i want to add some more characters.. what is the syntax to shorten this program.. Thank you
this is my program
#include <stdio.h> // #include <stdlib.h> // #include <ds89c4xx.h> // int d, d2; /* 0 = a 1 = b 2 = c 3 = d 4 = e 5 = f 6 = g */ /*------------------------------------- start delay program -------------------------------------*/ void delay(void); { for (d=0; d<1000; d++)//delay { for (d2=0; d2<1000; d2++)//delay { ; } } } /*------------------------------------- end delay program -------------------------------------*/ main() { while(1) { //H P2 = 0x00; P3 = 0x00; P1 = 0x76; delay(); //E P2 = 0x00; P3 = 0x76; P1 = 0x79; delay(); //L P2 = 0x76; P3 = 0x79; P1 = 0x38; delay(); //L P2 = 0x79; P3 = 0x38; P1 = 0x38; delay(); //O P2 = 0x38; P3 = 0x38; P1 = 0x3F; delay(); } }
[ Edited Sat Dec 15 2007, 10:53 pm ]
Sat Dec 15 2007, 11:12 pm
Thanks ajay for the reply, i want to shorten the code size because i want to display at least 100 characters.. is it possible sir?
Sun Dec 16 2007, 12:13 am
well yes you can do it.. use for loop and define an array to send values one by one..
something like this...
something like this...
unsigned char disp[9] = {0x00, 0x00, 0x76, 0x79, 0x38, 0x38, 0x3F, 0x00, 0x00}; unsigned char i; while(1){ for (i=0;i<7;i++){ P2 = disp[i]; P3 = disp[i+1]; P1 = disp[i+2]; delay(); } }
Sun Dec 16 2007, 01:03 am
im sorry sir, but i cant get the loop.. im using keil program and theres an error
this is the code
this is the code
#include <stdio.h> // #include <stdlib.h> // #include <ds89c4xx.h> // int d, d1; unsigned char i; unsigned char disp[9] = {0x00, 0x00, 0x76, 0x79, 0x38, 0x38, 0x3F, 0x00, 0x00}; delay() { for (d=0; d<1500; d++)//delay { for (d2=0; d2<1500; d2++)//delay { ; } } } main() while(1) { for (i=0;i<7;i++){ P2 = disp[i]; P3 = disp[i+1]; P1 = disp[i+2]; delay(); } } )
[ Edited Sun Dec 16 2007, 05:30 pm ]
Sun Dec 16 2007, 10:39 am
there surely is an error....
braces mising after main()
main()
{
while(1)
{
and the extra ')' in the end...
plz.. check..
main()
while(1)
{
braces mising after main()
main()
{
while(1)
{
and the extra ')' in the end...
plz.. check..
Powered by e107 Forum System