In this project, eight LEDs are connected to PORT B of a PIC microcontroller. A push-button switch is also connected to bit 0 of PORT A using a pull-up resistor. When the switch is pressed, the LEDs scroll to the right. Additionally, a switch is connected to bit 0 of PORT A to control the direction of scrolling. A PIC16F627 model microcontroller is utilized, operating from its 4 MHz internal clock. The LEDs are connected to eight pins of PORT B via 330-ohm current-limiting resistors. An external reset button is connected to the MCLR input of the microcontroller. The project includes a flow diagram. At the beginning of the program, the I/O direction is specified. A byte variable named Cnt is used as the loop variable. The program consists of an indefinite loop that begins by testing the switch. If the switch is at logic 1 (not pressed), the scrolling occurs to the left; if the switch is pressed, it is at logic 0, and scrolling occurs to the right. A 250 ms delay is included between each output. The software for the PICBasic language is provided. Initially, the addresses for PORTA, PORTB, TRISA, TRISB, and the CMCON register are defined. TRISA is set to 1, configuring bit 0 of PORTA as an input port, while TRISB is cleared to 0, setting all bits of PORTB as outputs. The push-button switch is connected to bit 0 of PORTA (RA0), which is normally pulled high to logic 1 using a resistor. When pressed, the pin goes to logic 0. The PORTA pins on the PIC16F627 microcontroller have dual functions, serving either as analog comparator inputs or digital I/O ports. The CMCON register controls the function of these pins, with CMCON set to 7 configuring them as digital I/O ports. Within the loop, the value of Cnt is sent to PORTB, and the PEEK instruction is used to read the switch setting. Bit 0 refers to bit 0 of variable B0, where the switch is connected. When the switch is pressed, the program jumps to a label for scrolling the LEDs to the right; otherwise, they scroll to the left. This loop repeats indefinitely with a 250 ms delay between each output.
The circuit design features a PIC16F627 microcontroller, which serves as the central control unit for the project. The microcontroller operates at a frequency of 4 MHz, providing sufficient speed for processing the input from the push-button switch and controlling the LED outputs. The use of PORT B allows for direct control of eight separate LEDs, each connected through a 330-ohm resistor, which limits the current to prevent damage to the LEDs.
The push-button switch connected to PORT A (specifically bit 0) enables user interaction, allowing the direction of the LED scrolling to be modified. The inclusion of a pull-up resistor ensures that the pin is held high when the switch is not engaged, providing a clear logic state for the microcontroller to read.
The program is structured to continuously monitor the state of the switch, leveraging a simple loop to determine the current scrolling direction. The use of a variable, Cnt, manages the LED positions and is updated in each iteration of the loop. The PEEK instruction reads the state of the switch, allowing the program to respond to user input effectively.
The configuration of TRISA and TRISB registers is critical, as it defines the operational roles of the respective pins. By setting TRISA to 1, the microcontroller designates bit 0 as an input, while clearing TRISB allows for output functionality across all associated pins. The CMCON register's configuration to 7 ensures that PORTA operates in digital mode, avoiding any interference from analog functions.
Overall, this project showcases the integration of a microcontroller with basic input and output components, demonstrating fundamental principles of digital electronics and microcontroller programming. The implementation of delays between LED state changes introduces a visually appealing effect, enhancing the user experience. The continuous loop structure ensures ongoing responsiveness to user interactions, making the circuit dynamic and engaging.In this project, 8 LEDs are connected to PORT B of a PIC microcontroller. Also a push-button switch is connected to bit 0 of PORT A using a pull-up resistor. When the switch is pressed the LEDs scroll to the right. The circuit diagram of the project is shown in Figure 1. The circuit in this project additionally a switch is connected to bit 0 of PO RTA to control the direction of scrolling. A PIC16F627 model PIC micro controller is used and the micro controller is operated from its 4 MHz internal clock. The LEDs are connected to 8 pins of PORT B using 330_ current-limiting resistors. An external reset button is connected to MCLR input of the microcontroller. The flow diagram of the project is shown in Figure 2. At the beginning of the program the I/O direction is specified. A byte variable called Cnt is used as the loop variable. The program consists of an indefinite loop and at the beginning of the loop the switch is tested. If the switch is logic 1 (i. e. switch is not pressed) then the scrolling is to the left and if the switch is pressed the switch is at logic 0 and scrolling is to the right.
A 250 ms delay is used between each output. The software for PicBasic language is given in Figure 3. At the beginning of the program PORTA, PORTB, TRISA, TRISB, and CMCON register addresses are defined. TRISA is set to 1 so that bit 0 of PORTA is configured as an input port. Similarly, TRISB is cleared to 0 so that all bits of PORTB are configured as outputs. Push-button switch is connected to bit 0 of PORTA (RA0). Normally this pin is pulled high to logic 1 by using a resistor. When the switch is pressed the pin goes down to logic 0. PORTA pins on the PIC16F627 microcontroller have dual functions and they can either be used as analog comparator inputs, or as digital I/O ports.
CMCON register is used to control the function of these pins. Setting CMCON to 7 configures PORTA pins as digital I/O ports. Inside the LOOP, the value of Cnt is sent to PORTB and the PEEK instruction is used to read the switch setting. Bit0 refers to bit 0 of variable B0 which is where the switch is connected. When the switch is pressed the program jumps to label PRESSED where the LEDs are scrolled right. When the switch is not pressed the LEDs are scrolled left. This loop is repeated forever with 250 ms delay between each output. Set port directions 🔗 External reference
Here is another project that creates a scrolling LED display. This display consists of 64 LEDs arranged in a matrix configuration. The anodes are driven through a driver circuit.
The scrolling LED display project utilizes a matrix of 64 LEDs,...
LED sequencer that follows the rhythm of music or speech, powered by a 9V battery, is a portable unit. The basic circuit illuminates up to ten LEDs in sequence, following the beat.
The LED sequencer circuit operates by detecting audio...
A circuit has been constructed that functions unexpectedly. The circuit utilizes red 5mm LEDs as diodes, a 3904 NPN transistor, and resistors as indicated in the schematic. Logically, pressing the push button normally open (PBNO) should result in the...
Using a PC parallel port to control external devices is a popular approach these days but I certainly couldn’t afford to tie up a PC for the few weeks leading up to Christmas just to flash a few LEDs!...
This indicator shows through a dual-LED see if a fuse is intact. The module is designed for 230 V AC. The green LED illuminates when the fuse is still good, the red lights when the fuse is broken. Perhaps...
The post discusses a Joule Thief circuit that drives and illuminates four 1-watt LEDs using a single 1.5V pencil cell.
The Joule Thief circuit is a minimalist boost converter designed to extract energy from low-voltage power sources, such as a...
We use cookies to enhance your experience, analyze traffic, and serve personalized ads.
By clicking "Accept", you agree to our use of cookies.
Learn more