Skip to content

4. Embedded programming

This week I was trying to learn about microcontrollers and how to program it.

Group Assignment

Our task in groups was to search about a certain microcontroller and learn about its specs, then every group share what they found with others.

Our microcontroller was “Adafruit Feather BlueFruit Sense nRF52840”

Indivisual Task

After taking a glance about microcontrollers everyone took a microcontroller and tried to program it using some codes

We used Arduino IDE to write codes

First of all you need to identify the microcontroller for the program like this

-This is the first screen of the Arduino IDE:

-From the top choose:

-Finally find your microcontroller

First Try

We used a written code to understand codes writing as illustrated: from “File” tap choose “Examples”, then “Basics” and finally “Blink”

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
}

Result video

Second Try

Trying to make some changes in the code by changing the time

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

Result video

Third Try

Trying to make the LED turn on and off by a random time between 25 and 200 millisecond

int randNumber;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}
void  loop() {
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));   // turn the  LED on/off
  randNumber = random(25, 200);
  delay(randNumber);                       //  wait 
}

Result video


Last update: July 30, 2024