Learn MCS51: Blink LED

Goal

Blink a LED on the board.

Schematic

To light LED1, we need the electric current flow from VCC to P10.

Code

#include "stc8fsdcc.h"
#include "delay.h"

void main(void) {
  P55 = 0; // allows electric current flow from VCC

  while (1) {
    P10 = 0;  // output 0v, led on
    delay_ms(1000);

    P10 = 1;  // output 5v, led off
    delay_ms(1000);
  }
}

Build and Upload

sdcc --Werror --model-small blink.c -o blink.hex
packihx blink.hex > upload.hex
stcgal -P stc8 upload.hex
Kauruus
CC BY-SA 4.0
Website built with Franklin.jl and the Julia programming language.