The timer of the C language programming of the single chip computer controls 4 LEDs to scroll and flash

Through the design of the single-chip computer course, master the programming method of C language, connect the theory to practice, and improve our brain and hands-on ability. Control the design of 4 LED scrolling and flashing systems through timers, master the use of timing/counters, and write simple programs to ultimately improve our logic abstraction capabilities.

The timer of the C language programming of the single chip computer controls 4 LEDs to scroll and flash

MCU timer control 4 LED scrolling flashing schematic

The timer of the C language programming of the single chip computer controls 4 LEDs to scroll and flash

MCU timer control 4 LED scrolling program design

/* Name: Timer Control 4 LEDs Scrolling

Note: 4 LEDs flash under the 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 program

Void main()

{

i=j=k=0;

P0=0xff;

TMOD=0x02; //Timer 0 working mode 2

TH0=256-200; //200us timing

TL0=256-200;

IE=0x82;

TR0=1; //Start timer

}while(1);

//T0 interrupt function

Void LED_Flash_and_Scroll() interrupt 1

{

If (++k "35) return; / / timed interrupt after several executions flashing

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; //each flashes for a while

j=0;

P0=0xff; close display

i++; //Switch to the next LED

}

Recommended reading: single-chip C language programming timer control single LED

BTC Miner


Bitcoin mining is the process of creating new bitcoin by solving puzzles. It consists of computing systems equipped with specialized chips competing to solve mathematical puzzles. The first bitcoin miner (as these systems are called) to solve the puzzle is rewarded with bitcoin. The mining process also confirms transactions on the cryptocurrency's network and makes them trustworthy.

For a short time after Bitcoin was launched, it was mined on desktop computers with regular central processing units (CPUs). But the process was extremely slow. Now the cryptocurrency is generated using large mining pools spread across many geographies. Bitcoin miners aggregate mining systems that consume massive amounts of electricity to mine the cryptocurrency.
In regions where electricity is generated using fossil fuels, bitcoin mining is considered detrimental to the environment. As a result, many bitcoin miners have moved operations to places with renewable sources of energy to reduce Bitcoin's impact on climate change.

Btc Miner,Bitmain S19 Xp,Bitmain Antminer S19 Xp,Antminer Bitmain S19 Xp 140Th

Shenzhen YLHM Technology Co., Ltd. , https://www.sggminer.com

This entry was posted in on