View previous topic :: View next topic |
Author |
Message |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri May 24, 2013 5:16 pm |
|
|
You've not responded to my previous post so I've rehashed your code again to make it more readable.
This time I've:-
1) Removed all references to interrupts.
2) Replaced PIN_Bx with led_xxxxx or PUSHBUTTON.
3) Changed the indenting once more.
Code: | #include <16F88.h> // Inclusion du Header correspondant au µC utilisé
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP // Paramétrage des fusibles du microcontrôleur
#use delay(clock=20000000)
// #use standard_io (B)
#define led_rouge PIN_B1
#define led_orange PIN_B2
#define led_vert PIN_B3
#define PUSHBUTTON PIN_B0
int8 count;
void main()
{
while(1)
{
// ORANGE blinks when push button is released
output_high(led_orange);
for (count=0;count<100;count++)
{
if (input(PUSHBUTTON)) break;
delay_ms(10);
}
output_low(led_orange);
for (count=0;count<100;count++)
{
if (input(PUSHBUTTON)) break;
delay_ms(10);
}
//...................
//????
// ORANGE fixed two seconds (just after the button be pressed)??????????????????????????????????????????
//????
//....................................
//FIRE tricolor starts, just after the extinction of solid orange 2seconde
//Red
output_high(led_rouge);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(30);
}
output_low(led_rouge);
//green
output_high(led_vert);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(60);
}
output_low(led_vert);
//orange
output_high(led_orange);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(30);
}
output_low(led_orange);
//red
output_high(led_rouge);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(50);
}
output_low(led_rouge);
}
}
|
I'll also tell you what I believe your code is doing:-
With the PUSHBUTTON==0 :-
a) Makes led_orange high for 1s.
b) Makes led_orange low for 1s.
c) Makes led_rouge high for a few machine cycles.
d) Makes led_rouge low.
e) Makes led_vert high for a few machine cycles.
f) Makes led_vert low.
g) Makes led_orange high for a few machine cycles.
h) Makes led_orange low.
i) Makes led_rouge high for a few machine cycles.
j) Makes led_rouge low.
k) Loops back to a.
With PUSHBUTTON==1 :-
l) Makes led_orange high for a few machine cycles.
m) Makes led_orange low.
n) Makes led_rouge high for 3s.
o) Makes led_rouge low.
p) Makes led_vert high for 6s.
q) Makes led_vert low.
r) Makes led_orange high for 3.
s) Makes led_orange low.
t) Makes led_rouge high for 5s.
u) Makes led_rouge low.
v) Loops back to l.
Is this what you want your code to do?
Mike |
|
 |
will
Joined: 28 May 2012 Posts: 24 Location: france
|
|
Posted: Sun Jun 02, 2013 9:16 am |
|
|
thank you very much
In the end my program should do this:
With the PUSHBUTTON == 0: -
a) Makes led_orange high for 1s.
b) Makes led_orange low for 1s.
c) Loops back to a.
With PUSHBUTTON == 1: -
l) Makes led_orange high for 3s.
m) Makes led_orange low.
n) Makes led_rouge high for 3s.
o) Makes led_rouge low.
p) Makes led_vert for high 6s.
q) Makes led_vert low.
r) Makes led_orange high for 3.
s) Makes led_orange low.
t) Makes led_rouge for high 5s.
u) Makes led_rouge low.
v) Loops back to the N
For the moment there is:
With the PUSHBUTTON == 0: -
a) Makes led_orange high for 1s.
b) Makes led_orange low for 1s.
c) Loops back to a.
With PUSHBUTTON == 1: -
l) ................. (does not work)
m) ................. (does not work)
n) Makes led_rouge high for 3s.
o) Makes led_rouge low.
p) Makes led_vert for high 6s.
q) Makes led_vert low.
r) Makes led_orange high for 3.
s) Makes led_orange low.
t) Makes led_rouge for high 5s.
u) Makes led_rouge low.
v) Loops back to n.
I would like to integrate the point L and M
A big thank you
Last edited by will on Sun Jun 02, 2013 1:08 pm; edited 1 time in total |
|
 |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sun Jun 02, 2013 10:01 am |
|
|
Quote: | For the moment there is:
With the PUSHBUTTON == 0: -
a) Makes led_orange high for 1s.
b) Makes led_orange low for 1s.
c) Loops back to a.
With PUSHBUTTON == 1: -
l) ................. (does not work)
m) ................. (does not work)
n) Makes led_rouge high for 3s.
o) Makes led_rouge low.
p) Makes led_vert for high 6s.
q) Makes led_vert low.
r) Makes led_orange high for 3.
s) Makes led_orange low.
t) Makes led_rouge for high 5s.
u) Makes led_rouge low.
v) Loops back to n.
| Is this your analysis of your previous code, or your current code?
If it's your previous code, I've already told you what it IS doing.
If it's new code then please show us your new code, then maybe someone will help.
None of the regulars here is going to write code for you.
Mike |
|
 |
will
Joined: 28 May 2012 Posts: 24 Location: france
|
|
Posted: Mon Jun 03, 2013 10:29 am |
|
|
Hello,
I do not mean of course that I write code.
I just like to know how to get solid orange for a moment.
I put the code below corresponds to this summary:
With the PUSHBUTTON == 0: -
a) Makes led_orange high for 1s.
b) Makes led_orange low for 1s.
c) Loops back to a.
With PUSHBUTTON == 1: -
l) ....makes led orange for high 4second............. (I do not know how)
m) .......makes led orange low.......... (I do not know how)
n) Makes led_rouge high for 3s.
o) Makes led_rouge low.
p) Makes led_vert for high 6s.
q) Makes led_vert low.
r) Makes led_orange high for 3.
s) Makes led_orange low.
t) Makes led_rouge for high 5s.
u) Makes led_rouge low.
v) Loops back to n.
Code: |
#include <16F88.h> // Inclusion du Header correspondant au µC utilisé
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP // Paramétrage des fusibles du microcontrôleur
#use delay(clock=20000000)
// #use standard_io (B)
#define led_rouge PIN_B1
#define led_orange PIN_B2
#define led_vert PIN_B3
#define PUSHBUTTON PIN_B0
int8 count;
void main()
{
while(1)
{
// ORANGE blinks when push button is released
output_high(led_orange);
for (count=0;count<100;count++)
{
if (input(PUSHBUTTON)) break;
delay_ms(10);
}
output_low(led_orange);
for (count=0;count<100;count++)
{
if (input(PUSHBUTTON)) break;
delay_ms(10);
}
//...................
//????
//????? ORANGE fixed 4 seconds
//???? I DO know how to do
//???
//FIRE tricolor starts, just after the extinction of solid orange 2seconde
//Red
output_high(led_rouge);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(30);
}
output_low(led_rouge);
//green
output_high(led_vert);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(60);
}
output_low(led_vert);
//orange
output_high(led_orange);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(30);
}
output_low(led_orange);
//red
output_high(led_rouge);
for (count=0;count<100;count++)
{
if (!input(PUSHBUTTON)) break;
delay_ms(50);
}
output_low(led_rouge);
}
} |
thank |
|
 |
will
Joined: 28 May 2012 Posts: 24 Location: france
|
|
Posted: Mon Jun 03, 2013 1:11 pm |
|
|
Yessssssssssss I found my fault . It works
A big thank you
thank you Mike
I will post my schedule this week
Have a nice evening |
|
 |
|