Skip to content

Embedded Programming

Group Assignment

  • Compare the performance and development workflows for other architectures
  • Documented by Terry AU

Microcomputers


OSEPP™ Uno R4

Specification
Microcontroller ATmega328P (Datasheet)
Clock Speed 16 MHz
Flash Memory 32 KB
SRAM 2 KB
Operating Voltage 5V
Input Voltage 6-12 V
Digital I/O Pin 14 (including 6 for PWM output)
Analog Input Pin 8
Dimensions 75.0 x 54.0 x 15.5 mm
Source Schematic

ATmega328P


It has an all-in-one extension board that can get almost all basic input and output devices.

OseppBlock IDE

Pros Cons
Function based on the STEM KIT is available UI and UX feels bad
C language preview available Blocks only

To program the board, it can either program by Arduino IDE or OseppBlock IDE. I’ve used OseppBlock IDE for this time.

Download the OseppBlock IDE first, then unzip the file then open the .exe file in the folder.

Then I can use the way of building puzzles/blocks to make code, it can build up the basic knowledge on logic training, but sometimes it is annoying to do something specifically.
You cannot modify it via programming language, although it can preview the C code.
Then I made a simple program that will light random colors, and when I press the button, it will become a red light breathing.

C++
void setup() {
  //button1
  pinMode(A1,INPUT);
  //rgb1
  pinMode(3,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
}

void loop() {
  if(digitalRead(A1)==LOW){
    analogWrite(3,255);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,206);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,154);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,103);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,51);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,53);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,103);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,154);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,206);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
    analogWrite(3,255);
    analogWrite(5,0);
    analogWrite(6,0);
    delay(100);
  } else {
    analogWrite(3,random(0,255));
    analogWrite(5,random(0,255));
    analogWrite(6,random(0,255));
    delay(100);
  }
}

Then I select the COM port and download it to the board.

Result:


BBC micro:bit

Specification
Microcontroller nRF52833 (Datasheet)
Clock Speed 64MHz
Flash ROM 512KB
RAM 128KB
Operating Voltage 1.8V .. 3.6V
Input Voltage 3-5 V
Dimensions 51.60 x 42.00 x 11.65 mm
Source Schematic


nRF52833


It has an extension board that can let users do more customize things, but I won’t use it this time.

Microsoft MakeCode for micro:bit

Pros Cons
Two programming language available, Python and Javascript C language is not available
A lot of official tutorial which help you code step by step Only mirco:bit board is usable

There is a web or software version to program the microbit. I’ve used the web version to make the code. Click Here to visit.
No login is required. Then click ‘New project’ to start a new workspace.

There are multi ways to program your code: Blocks, JavaScript and Python.

So if the A and B button has been pressed, the led will do a blinking diamond, then if isn’t, then do ‘<’ and ‘>’ icon.

Python
basic.show_string("A+B")

def on_forever():
    if input.button_is_pressed(Button.AB):
        basic.clear_screen()
        basic.show_icon(IconNames.SMALL_DIAMOND)
        basic.show_icon(IconNames.DIAMOND)
    else:
        basic.clear_screen()
        basic.show_leds("""
            . . . . .
                        . # . . .
                        # . . . .
                        . # . . .
                        . . . . .
        """)
        basic.show_leds("""
            . . . . .
                        . . . # .
                        . . . . #
                        . . . # .
                        . . . . .
        """)
basic.forever(on_forever)

After finishing the codes, click the left bottom ‘Download’ button to send the codes to the board.

Result:


Blink4Terry

Specification
Microcontroller Atmel SAMD11C14A
Clock Speed 48MHz
Flash Memory 16KB
SRAM 4KB
Operating Voltage 1.62V – 3.63V
Input Voltage 3.3 - 5V
Source Schematic

Atmel SAMD11C14A


Arduino IDE

Pros Cons
A lot of sample codes and easy to modify C language only
Support board that is not Arudion board The code highlighting sometimes go wrongly

I made a simple light on and off code:

C++
const int button = 2;
const int led =  4;

int pressed = 0;

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
}
void loop() {
  pressed = digitalRead(button);
  if (pressed == HIGH) {
    digitalWrite(led, LOW);
  } else {
    digitalWrite(led, HIGH);
  }
  delay(100);
}

Result:

Advance (for loop)

But the light on and off does not satisfy me, so I made a breathing and SOS light by using the ‘For’ statement according to For statement - zh-tw (Microsoft Docs)

C++
const int button = 2;
const int led =  4;

int pressed = 0;

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
}
void loop() {
  pressed = digitalRead(button);
  if (pressed == LOW) { 
    // if pressed = true
    // SOS ···---··· 
    analogWrite(led, 255);
    delay(100);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(100);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(100);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(500);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(500);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(500);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(100);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(100);
    analogWrite(led, 0);
    delay(100);
    analogWrite(led, 255);
    delay(100);
    analogWrite(led, 0);
    delay(1000);
  } else { 
    // if pressed = false
    for (int i = 0; i < 255; i++) {
      analogWrite(led, i);
      delay(1);
    }
    for (int i = 255; i > 0; i--) {
      analogWrite(led, i);
      delay(1);
    }
  }
}

Result:

Downloads

Latest Blink4Terry code - .ino


Last update: March 23, 2022