Embedded Programming 📋

🕘 Date / Time:

Hello there..^^. Hope a large smile finds its way to your face inspite off all the panic that COVID-19 pendemic is causing <3 ^^. Let's hope everything will be fine now that we're only on the eighth week of Fab Academy.. ^^

____________________________

A) Group Assignment:

"Compare the performance and development workflows for other architecture". That was what we are required to do as a group for this week .. ^^

____________________________

B) Individual Assignment:

Read a microcontroller data sheet program your board to do something, with as many different programming languages and programming environments as possible.



A. Datasheet Reading:

As a mechanical power engineer I don't have lots of things that I can understand from a microcontroller datasheet. 😅 yet I was able to get my utmost benefit from this figure.
It showed me pin numbers which of them are PWM and I used this information alot in designing the input and output boards when all I could do was just design during the lockdown.

ATtiny44 pinout.


B. Echo circuit programming:

Function:

My Echo board has a slider switch and 2 LEDs. I could do alot of different functions using just three of them. But I chose to greet myself in Morse code. 😂😂
For those of you who don't know what Morse code is check wikipedia it has a lot to say about it, but as a brief it's an encrypted way of communication that was invented by "Samuel Morse". Each Morse code symbol is formed by a sequence of dots and dashes. The dot duration is the basic unit of time measurement in Morse code transmission.
The duration of a dash is three times the duration of a dot. Each dot or dash within a character is followed by period of signal absence, called a space, equal to the dot duration. The letters of a word are separated by a space of duration equal to three dots, and the words are separated by a space equal to seven dots.

Message in Morse Code:

When the slider switch is on the Green LED blinks: "Hi Rowa":

. . . .   . .       . - .   - - -   . - -   . -

When the slider switch is off the Red LED blinks: "Bye Rowa":

- . . .   - . - -   .       . - .   - - -   . - -   . -


Durations:

Light on:
1- Dot = Basic Unit = 250 ms.
2- Dash = 3 x Basic Unit = 750 ms.
Light off:
3- Space between dots or dashes of a character = Basic Unit = 250 ms.
4- Space between characters in a word = 3 x Basic Unit = 750 ms.
5- Space between words in a sentence = 7 x Basic Unit = 1750 ms.

Program code in Arduino C:


    const int LED1= 7;
    const int LED2= 8;
    const int Slider= 2;
    int value;


    void setup() {
      pinMode(LED1,OUTPUT);
      pinMode(LED2,OUTPUT);
      pinMode(Slider,INPUT);
    }

    void loop() {

    value = digitalRead(Slider)

    if (value == HIGH) {

      //Morse Code Hi Rowa

      //Get Ready
          digitalWrite(LED1, HIGH);
          delay(3000);
          digitalWrite(LED1, LOW);
          delay(3000);

      //H
          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(750);

      //I
          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(1750);




    //R
          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(750);

      //O
          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(250);
          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(250);
          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(750);

      //W
          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(750);

      //A
          digitalWrite(LED1, HIGH);
          delay(250);
          digitalWrite(LED1, LOW);
          delay(250);

          digitalWrite(LED1, HIGH);
          delay(750);
          digitalWrite(LED1, LOW);
          delay(750);

          }



    else if (value == LOW) {

      //Morse Coode Bye Rowa

      //Get Ready
          digitalWrite(LED2, HIGH);
          delay(3000);
          digitalWrite(LED2, LOW);
          delay(3000);

      //B
           digitalWrite(LED2, HIGH);
          delay(750);
           digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(750);

      //Y
          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(750);


      //E
         digitalWrite(LED2, HIGH);
         delay(250);
         digitalWrite(LED2, LOW);
         delay(250);

         digitalWrite(LED2, HIGH);
         delay(250);
         digitalWrite(LED2, LOW);
         delay(1750);




    //R
          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(750);

      //O
          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(250);
          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(250);
          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(750);

      //W
          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(750);

      //A
          digitalWrite(LED2, HIGH);
          delay(250);
          digitalWrite(LED2, LOW);
          delay(250);

          digitalWrite(LED2, HIGH);
          delay(750);
          digitalWrite(LED2, LOW);
          delay(750);

      }

      }

        


Note:
There are of course other ways to do the function of this code with Arduino, but I chose to write it my way and it was much fun.😁

Getting to program my lovely Hello Echo board AKA "Awesome PCB 01 " :D, I was shocked to have done a really stupid mistake. It was that the slider switch is connected in a WRONG way and it can never switch between the two different states my circuit was intended to have. 😔😔
Even though it was so easy to correct my design to have the switch work properly, I didn't have time to re-mill another circuit, so I had to accept this one and toggle my code to over come not having a switch. 😕

      const int LED1= 7;
      const int LED2= 8;
  
      void setup() {
        pinMode(LED1,OUTPUT);
        pinMode(LED2,OUTPUT);
      }
  
      void loop() {
  
        //Morse Code Hi Rowa
  
        //Get Ready
            digitalWrite(LED1, HIGH);
            delay(3000);
            digitalWrite(LED1, LOW);
            delay(3000);
  
        //H
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(750);
  
        //I
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(1750);
  
  
  
  
      //R
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(750);
  
        //O
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(250);
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(250);
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(750);
  
        //W
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(750);
  
        //A
            digitalWrite(LED1, HIGH);
            delay(250);
            digitalWrite(LED1, LOW);
            delay(250);
  
            digitalWrite(LED1, HIGH);
            delay(750);
            digitalWrite(LED1, LOW);
            delay(750);
            
  
        //Morse Coode Bye Rowa
  
        //Get Ready
            digitalWrite(LED2, HIGH);
            delay(3000);
            digitalWrite(LED2, LOW);
            delay(3000);
  
        //B
             digitalWrite(LED2, HIGH);
            delay(750);
             digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(750);
  
        //Y
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(750);
  
  
        //E
           digitalWrite(LED2, HIGH);
           delay(250);
           digitalWrite(LED2, LOW);
           delay(250);
  
           digitalWrite(LED2, HIGH);
           delay(250);
           digitalWrite(LED2, LOW);
           delay(1750);
  
  
  
  
      //R
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(750);
  
        //O
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(250);
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(250);
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(750);
  
        //W
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(750);
  
        //A
            digitalWrite(LED2, HIGH);
            delay(250);
            digitalWrite(LED2, LOW);
            delay(250);
  
            digitalWrite(LED2, HIGH);
            delay(750);
            digitalWrite(LED2, LOW);
            delay(750);
  
        }
  
  
    


Hi Rowa - Bye Rowa in morse code. ❤

Downloadables: 💾

Arduino File.inoHere

___________________________________________


Šī¸ Row'a M. M. Othman - Fab Academy 2020