This simple post shows how to blink an LED using PIC16F887 microcontroller and CCS C compiler.
The LED here is connected to pin RA0 as shown in the circuit schematic below and easily that LED can be connected to other output pin or other LEDs can be added to the circuit which require code modification.
I this example there is no need for oscillator and MCLR circuits because the internal oscillator of the microcontroller is used at 8MHz and MCLR pin function is disabled (MCLR pin is configured as I/O pin).
Circuit diagram:
C Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* LED blink with PIC16F887 microcontroller Internal oscillator used @ 8MHz */ #include <16F887.h> #fuses NOMCLR NOBROWNOUT NOLVP INTRC_IO #use delay(clock = 8MHz) void main(){ setup_oscillator(OSC_8MHZ); // Set the internal oscillator to 8MHz while(TRUE){ // Endless loop output_high(PIN_A0); // LED ON delay_ms(500); // Wait 1/2 second output_low(PIN_A0); // LED OFF delay_ms(500); // Wait 1/2 second } } |
CCS C and Proteus simulation files can be downloaded from the following link:
Download
Discover more from Simple Circuit
Subscribe to get the latest posts sent to your email.