Skip to content

4. Embedded programming

This week we learnt about microcontrollers boards and how to program them.

What is a Microcontroller?

A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. You can think of it as a mini central processing unit (CPU).

A typical microcontroller includes a processor, memory and input/output (I/O) peripherals on a single chip.

Group Assignment

For the group assignment, each group had a different microcontroller board. Certain information had to be found about the microcontroller board like the number of pins and their type. More details can be found in the Group Assignment

Individual Assignment

Arduino

First we used an example code from the programme itself to know how to program the microcontroller board

I tried modifying the code by changing the delay time and adding more lines to the pre-existing code. You can find the code in Code Example.

TinkerCAD

Then, we tried a different programming environment which was easier to use than Arduino IDE. There was no need to download the program since it is an online tool. This is how the website looks when you open it

What makes TinkerCAD easier to use is that it has block coding in addition to the text code if you want to transfer it to Arduino IDE. Moreover, it has a nice simulation of the output of your code.

We were given a challenge which was to program the board to show a word in Morse Code. I chose the word SOS

Code Example

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {

  digitalWrite(LED_BUILTIN, HIGH);  
   delay(600);                      
   digitalWrite(LED_BUILTIN, LOW);    
   delay(200);

   digitalWrite(LED_BUILTIN, HIGH);  
   delay(200);                      
   digitalWrite(LED_BUILTIN, LOW);    
   delay(200);

   digitalWrite(LED_BUILTIN, HIGH);  
   delay(200);                      
   digitalWrite(LED_BUILTIN, LOW);    
   delay(200);

   digitalWrite(LED_BUILTIN, HIGH);  
   delay(200);                      
   digitalWrite(LED_BUILTIN, LOW);    
   delay(1000);

}

Last update: June 22, 2022