i just want a push button on port b0 and use port a0 as o/p
sbit b at RB0_bit; // b button
sbit led at RA0_bit; // led o/p
sbit button_direction at TRISB0_bit;
sbit led_direction at TRISA0_bit;
void main() {
if(b=0){
PORTA=!PORTA;
}
while(1);
}
there is no error in compile this code bt not working in proteus :'(
please help me :'(
please help me it is not working
Re: please help me it is not working
Hello psaundary and welcome to the forum
I'm not sure, but I think you may have to change a part of your code into this:
The main difference is the double equal sign '=' in the condition statement.
I didn't focus on your post since I'm a little busy at the moment. So, it might not solve your issue.
Please let me know if it didn't solve your issue
Best Regards
I'm not sure, but I think you may have to change a part of your code into this:
Code: Select all
void main()
{
While (1)
{
if(b==0)
{
PORTA=!PORTA;
}
}
}
I didn't focus on your post since I'm a little busy at the moment. So, it might not solve your issue.
Please let me know if it didn't solve your issue
Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!
Gotta catch them all!
not working again
may you give me mikroc program to on/off led by using pushbutton ..
sbit b at RB0_bit;
sbit led at RC0_bit;
sbit button_direction at TRISB0_bit;
sbit led_direction at TRISC0_bit;
void main() {
button_direction = 1;
led_direction=0;
if(b==1){
led=!led;}
while(1);
}
i am new in this field , please help me my compiler successfully compile the code bt if i use hex code in proteus ,port c0 reamin same every time when i press button
sbit b at RB0_bit;
sbit led at RC0_bit;
sbit button_direction at TRISB0_bit;
sbit led_direction at TRISC0_bit;
void main() {
button_direction = 1;
led_direction=0;
if(b==1){
led=!led;}
while(1);
}
i am new in this field , please help me my compiler successfully compile the code bt if i use hex code in proteus ,port c0 reamin same every time when i press button
Re: please help me it is not working
Hello psaundary
Of course I'm going to try to help you out
But the thing is, it's a little hard to help you without knowing the schematic, so could you please attach a picture here of your schematic?
It will give us a better picture of what's going on
Best Regards
Of course I'm going to try to help you out
But the thing is, it's a little hard to help you without knowing the schematic, so could you please attach a picture here of your schematic?
It will give us a better picture of what's going on
Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!
Gotta catch them all!
Re: please help me it is not working
As a beginner you should learn when you ask help in the Forum you need to give the inforamtion about your setup we can not see over your pc to your hardware
what you are doing
so what mcu are you using ??
what you are doing
so what mcu are you using ??
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------
Re: please help me it is not working
i am using pic 16f877a with 10 MHz crystal oscillator ..
i want use port b0 as input port and want to take response on port c0
in this fig i did not use led on c0 , i am using proteus professional 8 version there is no need to give vcc voltage source (i hope) for simulation ,actually i tested lcd program without using vcc for mcu.
please help i did not use led on c0 ,bcs Proteus can show port status if low blue if high it will be red
i want use port b0 as input port and want to take response on port c0
in this fig i did not use led on c0 , i am using proteus professional 8 version there is no need to give vcc voltage source (i hope) for simulation ,actually i tested lcd program without using vcc for mcu.
please help i did not use led on c0 ,bcs Proteus can show port status if low blue if high it will be red
Re: please help me it is not working
You have to pull MCLR pin up to VDD as in the real circuit ,as you did not do it, your model will never Run as the PIC is in Reset state
Attached a Proteus 8.2 model and mikroC code project of your PIC with Button which switch states on RC0 as you press the button and a Led on RC4 which Toggles every 100mSec
Attached a Proteus 8.2 model and mikroC code project of your PIC with Button which switch states on RC0 as you press the button and a Led on RC4 which Toggles every 100mSec
- Attachments
-
- 11.10.png (9.88 KiB) Viewed 2844 times
-
- Proteus_16F.zip
- (75.89 KiB) Downloaded 86 times
Last edited by p.erasmus on 11 Oct 2014 14:41, edited 1 time in total.
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------
-
- Posts: 138
- Joined: 27 Jul 2014 07:49
Re: not working again
Hi,psaundary wrote:may you give me mikroc program to on/off led by using pushbutton ..
sbit b at RB0_bit;
sbit led at RC0_bit;
sbit button_direction at TRISB0_bit;
sbit led_direction at TRISC0_bit;
void main() {
button_direction = 1;
led_direction=0;
if(b==1){
led=!led;}
while(1);
}
i am new in this field , please help me my compiler successfully compile the code bt if i use hex code in proteus ,port c0 reamin same every time when i press button
this correct code
Code: Select all
sbit b at RB0_bit;
sbit led at RC0_bit;
sbit b_direction at TRISB0_bit;
sbit led_direction at TRISC0_bit;
void main()
{
adcon1=6;
b_direction = 1;
led_direction=0;
led=0;// off led
while(1){
if(b==1){
led=!led;
delay_ms(250);
}
}
}
yupee we did it .
thank you to all ,for help me .. it is now working good and also i found that what mistake i did .. thanks to all
Re: please help me it is not working
good luck
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------