7. Embedded programming

This week was one of the most interesting weeks of worth since I got to experiment with electronics by programming on the Arduino IDE such that I can perform a specific function.

Delving Deep into the Intricacies of the Arduino Nano!

Firstly, it is important to note that Arduino Nano bases itself on the high-performance Microchip ATmega328P.

What is an Embedded System?

An embedded system is a microprocessor- or microcontroller-based system of hardware and software designed to perform dedicated functions within a larger mechanical or electrical system.

This can be accurately depicted by the diagram below:

What does Embedded Systems Programming imply?

Embedded systems programming is the programming of an embedded system in some device using the permitted programming interfaces provided by that system.

History of Embedded Operating Systems

The first modern, real-time embedded computing system was the Apollo Guidance Computer, developed in the 1960s by Dr. Charles Stark Draper at the Massachusetts Institute of Technology for the Apollo Program. The Apollo Guidance Computer was designed to collect data automatically and provide mission-critical calculations for the Apollo Command Module and Lunar Module.

In 1971, Intel released the first commercially available microprocessor unit – the Intel 4004 – an early microprocessor that still required support chips and external memory; in 1978 the National Engineering Manufacturers Association released a standard for programmable microcontrollers, improving the embedded system design; and by the early 1980s, memory, input and output system components had been integrated into the same chip as the processor, forming a microcontroller.

The microcontroller-based embedded system would go on to be incorporated into every aspect of consumers’ daily lives, from credit card readers and cell phones, to traffic lights and thermostats

Implementing with the Arduino Nano

- Pin Configurations Before using the Arduino Nano, we have to understand the basics of its structure such that we can easily work with it.

Every Pinout for the Arduino Nano can be neatly shown as follows:-

As we learn the pin configurations, we can move on to downloading the Arduino IDE to start working with the various functions of the Arduino Nano’s embedded programming.

I did so following a youtube tutorial that shows the step-by-step way to setting up the Arduino IDE on Mac OS X.

After successfully setting up the IDE, we can now start working on the function we want to code. We will start with a simple function from the built-in examples referred to as blink as it turns on the LED for a specific time period and then off for another time period we set in the code.

The function in real time can be depicted by the video below:-

  Blink

  Turns an LED on for 0.1 of a second, then off for another 0.1 of a second, repeatedly.

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

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a 
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a 
}

Using TinkerCad

TinkerCad is a program typically known for its user-friendly interface and simplicity. This program requires basic simple programming knowledge by using specific blocks with particular functions (or text if favored to be used by the user) that allow for a real world 3D simulation of the circuit.

Additionally, the features allow for the effective use of built-in Arduinos that can be simulated to achieve specific results using both input and output devices.

morsecode

MORSE CODE CHALLENGE

The challenge here is simple yet deceivingly simple as we will have to translate our encrypted message depicted by the LED within our circuit to its decrypted state using the morse code commands represented by dots, dashes, gaps between those dots and dashes, and finally gaps between each of the letters that consist our secret message.

Now our job is to make it a tad bit challenging and apply these morse code commands within our circuit such that the LED can represent our message. From there, your task is to write down the morse commands translated from the specific LED blinks and the time period between each blink (LED ON & OFF).

For the sake of simplicity, here is a simplified diagram of the morse commands and the associated letters.

morsecode

On the diagram, we can see the representation of each of the morse commands in units of time. Let us make this easy on ourselves and represent one unit of time as simply being 1/2 of a second.

The spaces or gaps will naturally be LED OFF and the dashes and dots will be LED ON.