/.Project: Push Button ON/OFF MCU: 16F877A/ 8MHz/ Author: Asanka Lakmal Morawaka Compiler: MikroC./. MikroC PRO for PIC 7.2.0 can be downloaded from our website for free. The program lies within Development Tools, more precisely IDE. The mikroC PRO for PIC installer is commonly called mikroC PRO PIC.exe, mikroC Pro PIC32.exe or mikroC.exe etc. This program is a product of MikroElektronika. Our antivirus check shows that this download is safe.
mikroC PRO for PIC is a full-featured ANSI C compiler for PIC devices from Microchip®.
se-uql#toggleEditor'>
0
1answer
In MircoC Pro for dsPIC How can I setup the watchdog timer?
I need to set the FWDT to have the WDT be on, the prescaler be 1 and the postscaler be 12.I can't find any documentation on how to do this programmatically, or any way at all. I can see from the ...
Matt Ellen7,48922 gold badges5353 silver badges7777 bronze badges
0
1answer
Uart1 & Uart3 not working at same time in pic18fk67k40
I am using PIC18f67k40 with internal clock at 8Mhz (IDE 7.5).I did led blinking and simple UART1 transmit that works fine.Next while trying UART1 & UART3 at same time, only UART1 works... (...
0
1answer
Problem with receiving correct integer from c# inteface
I am programming a dynamic C# interface to show real time states of my line follower robot sensors and motors. I am also sending a threshold of sensors to a microcontroller.My code is:char uart_rd[...
1
1answer
Receiving number of 3 digits from c# interface with PIC16F877 (MikroC IDE)
I am programming a dynamic C# interface to show real time states of my line follower robot sensors and motors. I am also sending a threshold of sensors to a microcontroller.Now I want to receive the ...
0
0answers
Have you ever interfaced a MAX44009 sensor with a uC?
I recently tried to program, using the free download version of MikroC for dsPIC IDE, a MAX44009 sensor to interface with PIC24FJ64GB002 microcontroller. The lux result of the sensor should be ...
-1
1answer
Send SMS GSM Click
'I'm using the example code of Mikroe for the GSM click with a few additional lines of code to send a sample text message. But I'm having problems with the 'sendSMSmsg' function where msg is ...
0
2answers
Button activated UART message
'I'm trying to use the button that when it is pressed, it triggers to send a string message via UART, but upon running the code, it always detect the button to be 'always pressed' which is not ideal. ...
1
1answer
STM32F107 UART Bootloader mikroC
I try to adopt the UART Bootloader from mikroelektronika, written for the STM32F051r8 (https://www.st.com/resource/en/datasheet/stm32f051r8.pdf)to a STM32F107VCT7 (https://www.mouser.de/datasheet/2/...
0
0answers
Control DC motor using PWM technique, pic18 and mikroC compiler
i need to control a DC motor using a microcontroller, PIC18F25k22.I have a part of the code in MIKROC compiler, but i don't know how to make it all work togheter, and i need to improve it.I will let ...
1
1answer
How to create a timer/clock that can send its value back,stored in a variable, ONLY made with delays in C & on mikroC
As a C beginner, I struggle alot to solve this problem of mine :I am working on a project where I basicly have to program a PIC (microchip) in C using the mikroC platform.What I'm trying to ...
0
0answers
I want a code mikroc for pic for automatic curtain control system?
The system allows to raise or lower the curtain at scheduled times, these can be modified using LCD interface and push buttons?
-3
1answer
PIC Microcontroller with GSM module
How do I get a caller identity from sim900 using pic16f877A microcontroller meanwhile, I can make call, send SMS and answer calls but I want to be able to compare an incoming call identity with a ...
0
0answers
Connect 4 microcontrollers together using UART serial communication to a pc
**Is there a way for connecting 4 microcontrollers together using UART even if it has one UART module in each one of them(18f452) to send data from three of them to the master(18f4550) for display it ...
1
0answers
Shift left command in LCD not working properly
So I'm writing a program in MikroC that prints a text on a LCD and shifts it every 13 ms right. When the text is fully shifted to the right it shifts it to the left and it goes like that back and ...
0
1answer
RBIE interrupt works only once - PIC16F877A
In my code, I have two interruptions, one is coming from the overflow of the TMR0, and the other one is when a button is pressed. this is the code in MikroC :int compt = 0;int seconds = 10 ;int ...
153050per page
Active2 years, 7 months ago
I'm using MikroC to try and program my PIC16f62 Microcontroller. I've managed to get my outputs working (I can have LEDs turn on, etc) but I can't seem to get the inputs work.
Here is my current code:
I don't know if the problem is that I'm not configuring the PORT correctly or if I'm checking whether or not the button is pressed incorrectly.
Any help is appreciated. Thanks.
Lundin121k1717 gold badges171171 silver badges285285 bronze badges
Shahmeer NavidShahmeer Navid34133 gold badges99 silver badges1717 bronze badges
2 Answers
rajesh6115rajesh6115
You are probably reading the port pin correctly, however because you're toggling the LED on and off when you detect a press, your eye can't see the result.
For example, a clock rate of 1Mhz will have the on/off toggle approximately 150,000 times per second (1,000,000 cycles / ~3 ASM instructions per loop / 2 loops to turn on then off).
I would suggest taking the approach of having the LED match the state of the input pin.
This technique is similar to what Rajesh suggested, but provides a bit more direct feedback on whether the input pin is set or not.
If that doesn't work, then something with your setup of the TRISA is not correct. You may want to try this:
RossRoss1,30544 gold badges1616 silver badges2424 bronze badges