Skip to content

Embedded Programming

Embedded programming refers to the process of writing software specifically for embedded systems. An embedded system is a specialized computer system designed to perform dedicated functions within a larger system or device. These systems are often found in various electronic devices such as microcontrollers, industrial machinery, medical devices, automobiles, home appliances, and more.

Microcontroller

A microcontroller is a small, self-contained computer system on a single integrated circuit (IC). It consists of a central processing unit (CPU), memory (both volatile and non-volatile), input/output (I/O) peripherals, and various other components necessary for its operation. Microcontrollers are designed for embedded systems and are commonly used in a wide range of electronic devices.

Group Assignment

Arduino Nano 33 BLE Sense

The Arduino Nano 33 BLE Sense is a compact microcontroller board based on the nRF52840 chip from Nordic Semiconductor. It is part of the Arduino Nano series and is specifically designed for projects that require Bluetooth Low Energy (BLE) connectivity and a wide range of built-in sensors. The Nano 33 BLE Sense board provides a powerful platform for developing IoT applications, wearable devices, and sensor-based projects.

Microcontroller Name How many pins it has The types of pins Type of sensors Type of Languages you can program it with
Arduino Nano 33 BLE Sense 30 Built-in LED Pin 13. Digital I/O Pins 14. Analog input pins 8. PWM pins 5 built in sensors-BMI270 -(3-axis accelerometer + 3-axis gyroscope) + BMM150 (3-axis Magnetometer) C++ , Python

Pinout Diagram

Arduino Nano 33 BLE

My Groupmate Ali’s Link to his Group Assignment

Arduino MKR

To access the documentation about MKR, please visit my colleague Zainab’s website.

Adafruit Feather nrf52840

To access the documentation about Adafruit Feather nrf52840, please visit my colleague Sayed Ali’s website.

Individual Assignment

Programming Microcontroller

I program the microcontroller three programs using Arduino IDE and one using Tinkercad and one using Mu Editor. The order of program it dependent in the difficult of the program.

First Program

The program about blink led.

By Using Arduino IDE

In Arduino IDE you have a ready code in example. You must go to tools and change some of sitting to upload the code in my case I have a Arduino Nano so I did this step. You need in step 10 to choose the port that connect to the Arduino you want to program it. Then you can upload the code.

The code

// 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);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

The result of the code in the next video.

By Using Tinkercad

You can change the time for blink just by change the number in 1 and 2

Second Code

The second code is about you make a word by using Morse Code.

By Using MU Editor

I was trying to upload the code using MU Editor but I can not open the microcontroller to upload the file. The code is

import serial
import time

arduino = serial.Serial("COM16", 9600)
time.sleep(2)
print("Enter 1 to turn ON LED and 0 to turn OFF LED")

while 1:

    datafromUser = input()

    if datafromUser == "1":
        arduino.write(b"1")
        print("LED  turned ON")
    elif datafromUser == "0":
        arduino.write(b"0")
        print("LED turned OFF")

By Using Arduino IDE

Like the first code you need to do the same step after example because the code is not in example. the code I use is

void setup() {

  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);  
  delay(2000);
  digitalWrite(LED_BUILTIN, LOW);   
  delay(3000);

   digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
   digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
   digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
   digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);     
  delay(3000);

  digitalWrite(LED_BUILTIN, HIGH);  
  delay(2000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);  
  delay(2000);                     
  digitalWrite(LED_BUILTIN, LOW);      
  delay(3000);   

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

  digitalWrite(LED_BUILTIN, HIGH);  
  delay(2000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
   digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(500);
   digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);                     
  digitalWrite(LED_BUILTIN, LOW);   
  delay(5000);


}

The video next show the result of the code.

Can you guess the correct word? Write it in the comment on YouTube. And make another word by using Morse code

Third Code

The code is about make the LED on for duration that write on serial monitor.

By Using MU Editor

I was trying to upload the code using MU Editor but I can not open the microcontroller to upload the file. But I think the code is correct. The code is

import serial
import time

arduino = serial.Serial("COM16", 9600)
time.sleep(2)
print("Enter 1 to turn ON LED and 0 to turn OFF LED")

while 1:

    datafromUser = input()

    if datafromUser == "1":
        arduino.write(b"1")
        print("LED  turned ON")
    elif datafromUser == "0":
        arduino.write(b"0")
        print("LED turned OFF")

By Using Arduino IDE

The code I use is

int datafromUser=0;
void setup() {

  pinMode( LED_BUILTIN , OUTPUT );
  Serial.begin(9600);
}

void loop() {

  if(Serial.available() > 0)
  {
    datafromUser=Serial.read();
  }

  if(datafromUser == '1')
  {
    digitalWrite( LED_BUILTIN , HIGH );
    delay(1000);
    digitalWrite( LED_BUILTIN, LOW);
  }
   else if(datafromUser == '2')
  {
     digitalWrite( LED_BUILTIN , HIGH );
    delay(2000);
    digitalWrite( LED_BUILTIN, LOW);
  }
  else if(datafromUser == '3')
  {
     digitalWrite( LED_BUILTIN , HIGH );
    delay(3000);
    digitalWrite( LED_BUILTIN, LOW);
  }
  else if(datafromUser == '4')
  {
     digitalWrite( LED_BUILTIN , HIGH );
    delay(4000);
    digitalWrite( LED_BUILTIN, LOW);
  }

}

The video will be expelling how the code run.


Last update: October 5, 2023