Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 void main() { TRISE = 0X03; PORTE.F2 = 0; TRISC.F3 = 1; while(1) { if(PORTE.F1 == 1) PORTE.F2 = 0; //UP if(PORTE.F0 == 1) PORTE.F2 = 0; //dn if(PORTC.F3 == 1) PORTE.F2 = 1; //ok } }
void main()
{
TRISE = 0X03;
PORTE.F2 = 0;
TRISC = 0x08;
while(1)
{
if(PORTE.F1 == 1)
Delay_ms(150);
if(PORTE.F1 == 1)
PORTE.F2 = 0; //UP
if(PORTE.F0 == 1)
Delay_ms(150);
if(PORTE.F0 == 1)
PORTE.F2 = 0; //dn
if(PORTC.F3 == 1)
Delay_ms(150);
if(PORTC.F3 == 1)
PORTE.F2 = 1; //ok
}
}
i tried but still not workingTry this code
Code:void main() { TRISE = 0X03; PORTE.F2 = 0; TRISC = 0x08; while(1) { if(PORTE.F1 == 1) Delay_ms(150); if(PORTE.F1 == 1) PORTE.F2 = 0; //UP if(PORTE.F0 == 1) Delay_ms(150); if(PORTE.F0 == 1) PORTE.F2 = 0; //dn if(PORTC.F3 == 1) Delay_ms(150); if(PORTC.F3 == 1) PORTE.F2 = 1; //ok } }
You need to give debounce for buttons.
When OK is pressed led will turn ON. pressing up or down will turn off the led.
?????????????did you press another button & post it.
Thank you for interest but i tried and still LED on and cant be OFFplease press up/down button & check it.
- - - Updated - - -
have you try it.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 void main() { TRISE = 0X03; PORTE.F2 = 0; TRISC.F3 = 1; while(1) { if(PORTE.F1 == 1) PORTE.F2 = 0; //UP if(PORTE.F0 == 1) PORTE.F2 = 0; //dn if(PORTC.F3 == 1) PORTE.F2 = 1; //ok delay ms(100); } }
There is (_) missing in(delay ms(100); and i completed it but still not working??try this code.
void main()
{
TRISE = 0X03;
PORTE.F2 = 0;
TRISC.F3 = 1;
while(1)
{
if(PORTE.F1 == 1) PORTE.F2 = 0; //UP
if(PORTE.F0 == 1) PORTE.F2 = 0; //dn
if(PORTC.F3 == 1) PORTE.F2 = 1; //ok
delay ms(100);
}
}
Hi all,
My project is very simple that is keypad UP,DN & OK, LED
When i press ok LED is ON and OFF if i pressed UP or DN
UP----> porte.f1
DN----> porte.f0
OK----> portc.f3
LED---> porte.f2
and this is the code
void main()
{
TRISE = 0X03;
PORTE.F2 = 0;
TRISC.F3 = 1;
while(1)
{
if(PORTE.F1 == 1) PORTE.F2 = 0; //UP
if(PORTE.F0 == 1) PORTE.F2 = 0; //dn
if(PORTC.F3 == 1) PORTE.F2 = 1; //ok
}
}
The problem that i can turn LED on and cant off it
I am using mikroC V8.2.0.0
:?::?::?::?::?::?::?::?::?:
in port E 1st & 2nd bit are set as input & others are o/p.
switch is connected to pull down to gnd. the other terminal of the switch is connected to vcc.
That make pin 0 & 1 are I/P for DN & UP switches and pin 2 O/P for the LEDTRISE = 0x03
To make pin 3 I/P for OK switchTRISC.F3 = 1
Micro pin is pulled down with resistor and switch get 5V to the pinSecond -- How have you connected your switchs ? Are they switch-to-GND with pullup-to-Vcc ? Or something different ? If its switch-to-GND then when the switch is ON, your input level will be 0 and not 1. So you will have to check for PORTE.Fx == 0 etc
thank you for your interestI believe focusing on these 2 questions will give you the answer to fix it.
cheers!
That make pin 0 & 1 are I/P for DN & UP switches and pin 2 O/P for the LED
and
To make pin 3 I/P for OK switch
I cant run micro before disconnecting the programmer (it may be lower MCLR pin)
This part are from already running program ???!!!
I will try tomorrow get it in interrupt subroutine then use flags
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?