Through the design of the microcontroller course, students will gain a solid understanding of C programming and learn how to apply theoretical knowledge in practical projects. This hands-on experience helps improve both cognitive and technical skills. By using timers, students can control a 4-LED scrolling and flashing system, gaining proficiency in working with timers and counters, and writing simple programs that enhance their logical thinking and abstraction abilities.
MCU Timer Control 4 LED Scrolling Flashing Schematic
MCU Timer Control 4 LED Scrolling Program Design
/* Name: Timer Controlled 4 LED Scroll and Flash
Note: This program makes 4 LEDs flash and scroll using timer control.
*/
#include "reg51.h"
#define uchar unsigned char
#define uint unsigned int
sbit B1 = P0^0;
sbit G1 = P0^1;
sbit R1 = P0^2;
sbit Y1 = P0^3;
uint i, j, k;
// Main function
void main()
{
i = j = k = 0;
P0 = 0xff; // All LEDs off initially
TMOD = 0x02; // Timer 0 in mode 2 (8-bit auto-reload)
TH0 = 256 - 200; // Set timer for 200 microseconds
TL0 = 256 - 200;
IE = 0x82; // Enable global and timer 0 interrupts
TR0 = 1; // Start timer
while(1); // Infinite loop
}
// Timer 0 interrupt service routine
void LED_Flash_and_Scroll() interrupt 1
{
if (++k == 35) return; // After 35 interrupts, skip to next LED
k = 0;
switch(i)
{
case 0: B1 = ~B1; break;
case 1: G1 = ~G1; break;
case 2: R1 = ~R1; break;
case 3: Y1 = ~Y1; break;
default: i = 0;
}
if (++j == 300) return; // Delay between each LED change
j = 0;
P0 = 0xff; // Turn off all LEDs
i++; // Move to next LED
}
Recommended Reading: Microcontroller C Programming - Timer Controlled Single LED
Pyne Pod Boost 8500 Disposable Vape
Pyne Pod Boost 8500 Disposable Vape is a powerful choice. It has a 550mAh rechargeable battery, which can provide you with around 8500 puffs of great flavour. You won't have to wait long to get back to vaping because it charges quickly in just 30 minutes thanks to the Type-C charging port. This vape uses a mesh coil to give you the best flavour and lots of vapour. It also has features like a battery and e-liquid display, a double-click for dual activation, and a flavour booster, so you can customize your vaping experience. Turning the device on and off is easy too. With its big puff capacity and speedy charging, the Pyne Pod Boost 8500 is all about offering a great and trouble-free vaping experience.
Disposable Vape,Yingyuan Vaporizer. E-cigarettes
Shenzhen Yingyuan Technology Co.,ltd , https://www.yingyuanvape.com