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 CCS Technical Support

pushbutton 16F88
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
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri May 24, 2013 5:16 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Sun Jun 02, 2013 9:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 02, 2013 10:01 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Mon Jun 03, 2013 10:29 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Mon Jun 03, 2013 1:11 pm     Reply with quote

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
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