Skip to content

5. Embedded Programming

This week I worked on Programming an embedded light bulb in microcontroller using Arduino IDE. Also we used TINKERCAD to do simulation on Arduino UNO microcontroller.

Group assignment

In the group aassignment we given different microcontroller and we should research about them this what we got Click here

Arduino IDE with C++

Arduino IDE is a software help us Programming many kind of microcontroller and one of them is what we used here Adafruit Feather nRF52840. Firstly ,I download the software from this website Arduino IDE After downloading it I followed this tutorial to setup everything. after that I did the blink test so first I go to examples-basics-blink and from here I used the code here is as the photo above show that the delay time for blinking is 1sec between each blink so High mean this for the bulb is on and low for the bulb is off as you see above the bulb will be 1sec on and 1 sec off and will do that in a loop because void loop() function. and I upload it by clicking this button.

Afterward I tried to random blink test using random(min, max)that give random number between the value you specified: -

Tinkercad

Here we used another method to program and simulate in the same time the microcontroller it’s easy to use and interactive in the same time. so here we used the microcontroller bulb for morse code - firstly, I translate the ‘get’ to morse code using this website - secondly, I convert the morse code into the embedded bulb using tinkercad - for dash 1sec delay for dot 0.5sec delay (light on) also between letter 1sec delay (light off) and between word 2sec delay (light off) and this is the result code.

  • I did also convert this blocks to c++ language and this the result:
// C++ code
//
int counter;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  for (counter = 0; counter < 2; ++counter) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000); // Wait for 1000 millisecond(s)
    digitalWrite(LED_BUILTIN, LOW);
    delay(500); // Wait for 500 millisecond(s)
  }
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500); // Wait for 500 millisecond(s)
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500); // Wait for 500 millisecond(s)
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(LED_BUILTIN, LOW);
  delay(2000); // Wait for 2000 millisecond(s)
}

Last update: August 17, 2022