push botton project using mikroc pro to control 2led light in 3mode
good day everyone
pls can anyone help me out, i am working on a project with mikroc pro dat uses one push botton to control two led such that the initial state of both led is off,
when d botton is press ones, one led comes on.
when the button is pressed d second time, the second comes on
when pressed for the last time, both go off
Re: push botton project using mikroc pro to control 2led light in 3mode
Hi,
No question?
No problem?
Don't expect anybody does your job for free.
Please elaborate your post.
Write your ideas.
Post your flow chart, even a hand made is good.
Post your code.
Post how you tested your code.
Post your expectations and what you see instead.
What and how did you try to find the source of the problem? What are the results?
Push button project using Mikroc pro to control 2 led light in 3 mode
am working on a design with mikroc that switches 2 led in 3 mode;10,01and 00 wit a push button.
but d code i write is only giving me on and off. i really dont knw the right command to use...here is the code
anselc=0;
anseld=0;
trisd_bit=0;
trisc_bit=1;
portd.rd0=0;
portd.rd1=0;//switch on only d0if(portc.rc0==0){
portd.rd0=1;
portd.rd1=0;}//on second press switch on only d1if(portc.rc0==0){
portd.rd0=0;
portd.rd1=1;}//on third press switch off both d0 and d1if(portc.rc0==0){
portd.rd0=0;
portd.rd1=0;}while(1);}}
Re: push botton project using mikroc pro to control 2led light in 3mode
Start simpler - just get a single LED to flash at the rate you want (e.g. 1 second on and 1 second off). Getting started with your first program can be quite a learning curve.
There are a number of tutorials available but make sure that you select one that relates to your particular device (or family).
Once you have that working, then you can expand it to do what you want. As part of that later step, read up on finite state machines - while the concept might be a bit strange at first (start with pencil and paper - always a good place to start) it wil do what you want and, again, can be expanded up to some seriously advanced programming if necessary.
Susan
Re: push botton project using mikroc pro to control 2led light in 3mode
Think about what happens when the button is released or continuously held down. I think you want to detect a transition (an edge) on PORTC.F0 rather than just it's logic state.
Hint: read it, store it, compare it with what you read next time, that way you can see if the logic state changed over time.
Re: push botton project using mikroc pro to control 2led light in 3mode
Also which MCU are you using?
The above code will not work in may devices that use the older style of analog/digital selection register (i.e. ADCON1 or ANSx or ADxPCFGL vs ANSELx).
Also knowing which device you are using means we can suggest better ways if debouncing (and other operations) depending on what capabilities are built in.
Susan
am try to using 2 push botton to control a single led with mikroc such that when the button 1 is pressed ones, it on the first led for a time delay of 1s...when the button is pressed again for a debounced tym of 1s, it switches on d led 2 for a tym delay of 2s....same operation i need for d 2 push button, performing same operation on d led without any interuption.