View previous topic :: View next topic |
Author |
Message |
zeyad
Joined: 24 Feb 2015 Posts: 22
|
for loop |
Posted: Fri Feb 27, 2015 2:20 am |
|
|
how to merge these lines into a for loop???
Code: |
void s1( )
{
output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);
output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9);
delay_ms(50);
} |
|
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Fri Feb 27, 2015 3:27 am |
|
|
Please mods ban this numpty |
|
|
zeyad
Joined: 24 Feb 2015 Posts: 22
|
for loop |
Posted: Fri Feb 27, 2015 3:45 am |
|
|
oxo wrote: | Please mods ban this numpty |
english please |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri Feb 27, 2015 11:49 am |
|
|
You appear to be repeating the following code several times over Code: | delay_ms(50);output_b(3);
delay_ms(50);
output_b(6);
delay_ms(50);
output_b(12);
delay_ms(50);
output_b(9); | Get a basic 'C' manual. You will find it in there.
Mike |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Feb 27, 2015 1:39 pm |
|
|
this code is as foolish as the year is long.....
set the port ONCE
and if you need all that delay - add it up and execute a SINGLE delay.\
two lines of code do it all and
there will be no change in function performance except
a lot less code space will be used.
Proteus only teaches you that to really learn,
you should work with hardware instead.
you posted this same ridiculous code in another thread and still don't say what on earth you think it accomplishes. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Feb 27, 2015 3:34 pm |
|
|
stepping motor drive ?
3,6,12,9 for ever......
rotates 2 bits
ad nauesum
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
|
zeyad
Joined: 24 Feb 2015 Posts: 22
|
thank you pcm programmer. it works |
Posted: Mon Mar 02, 2015 9:44 pm |
|
|
thank you pcm programmer. it works |
|
|
zeyad
Joined: 24 Feb 2015 Posts: 22
|
stepper motor |
Posted: Mon Mar 02, 2015 9:48 pm |
|
|
temtronic wrote: | stepping motor drive ?
3,6,12,9 for ever......
rotates 2 bits
ad nauesum
Jay |
yes |
|
|
|