Embedded programming

During this week, I learnt about microcontrollers boards and how to program them.

Week04

There are two assignments in this week:

  • Group assignment: Search for different types of micro-controllers boards and compare between them, then search for different programming languages, compare between them and how many can you use to program the same micro-controllers.

  • Individual assignment: Program the micro-controller board using two different programming languages and two programming environments.
  • What is micro-controller?

    A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. It typically includes a processor, memory, and input/output peripherals on a single chip. Microcontrollers are widely used in devices like appliances, automotive systems, and robotics for automation and control tasks.


    Ac vs. Dc

    In electronics, AC (Alternating Current) and DC (Direct Current) are two fundamental types of electrical current, each with distinct characteristics, the main differences between AC and DC are:

    1. Direction of Flow: AC periodically reverses direction, while DC flows in a constant direction.
    2. Waveform: AC is generally represented as a sine wave, whereas DC is represented as a flat line (constant voltage).
    3. Applications: AC is commonly used for power distribution in homes and industries, while DC is used in batteries, electronics, and devices that require a steady voltage.

    Download free bootstrap 4 landing page, free boootstrap 4 templates, Download free bootstrap 4.1 landing page, free boootstrap 4.1.1 templates, meyawo Landing page
    Task 1 - Group assignment

    We got a many micro-controller boards, each group take one and start search about it to find a specific information. You will find the information here

    Task 2 - Arduino software

    I start work in arduino software v2.3.2, before doing anything, I do a change in the setting to show verbose output



    I got a micro-controller board with type arduino Nano so I start link it with the laptop then search for it in the software. The micro-controller board's search bar is in the top of the page, when I open it I search for my board type.





    Before that, to know the type of my micro-controller board (While it's not written on it) I go back to the table that we do it in day 1 and I find it as a Arduino Nano classic.
    To test the linking between the software and the board, I open an example code from the software itself and upload it.






    And it's work!


    This code turn on and off the light in the board automatically each second.


    I then change the time of turning on and off to 0.5 second.


    The instructor then presents us with a three challenges. One of them is to program your microcontroller to transmit a one-word message in Morse code, and then challenge a friend, relative, coworker, or teacher to decipher it.
    Referee to this schedule:

    This is the Medium mode challenge and it was easy, just need a little thinking.
    I do it for a word SOS:

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

    And it's work!


    The second challenge was: "you select the duration of the light being on and off while the program is running by entering it in the serial monitor. Write a code that takes the data from the serial monitor and delays by that amount of time." And this is the hard mode challenge and need some research.
    I wasn't know what is a serial monitor and how can I open it so I asked Chat GPT, I found a good information about it and how can use it then I start work on the code.
    First, I worked in the same window that I worked in for the last code but with other tab and it didn't work, that's because the board get two order when I upload it, one from each tab.
    I then move it in another window.
    I test the serial monitor with a simple code to write "Hello world!", and it's work.


    For a challenge, I try to write code with function "serial.delay(3000)" but it didn't work so I think to add a variable for a delay time.

    The code came like this:

    
     int delayTime = 1000;
     void setup() {
       Serial.begin(9600);
       pinMode(LED_BUILTIN, OUTPUT);
     }
     
     // the loop function runs over and over again forever
     void loop() {
       delayTime = Serial.parseInt();
       Serial.print(delayTime);
     
       digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
       delay(delayTime); 
       digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
      delay(delayTime); 
     }
            


    It's work, but it need to improve, while I couldn't able to see the result well.
    And end up with this code and result:
    
     int delayTime = 3000;
     void setup() {
       Serial.begin(9600);
       pinMode(LED_BUILTIN, OUTPUT);
     }
                
    void loop() {
    if (Serial.available() > 0) {
      delayTime = Serial.parseInt();
      Serial.println(delayTime);
    
      digitalWrite(LED_BUILTIN, LOW);
      delay(delayTime); 
      digitalWrite(LED_BUILTIN, HIGH);
     delay(delayTime);
       digitalWrite(LED_BUILTIN, LOW);
      delay(delayTime); 
      digitalWrite(LED_BUILTIN, HIGH);
     delay(delayTime);
    }
    
    digitalWrite(LED_BUILTIN, LOW); 
    }
            

    Download free bootstrap 4 landing page, free boootstrap 4 templates, Download free bootstrap 4.1 landing page, free boootstrap 4.1.1 templates, meyawo Landing page
    Task 3 - Thoony software

    This day I start work with another programming software which is "Thonny", I used micro-python language to work in.
    With this software I used a micro-controller called "KidsIOT", It's a micro-controller with a box that keep connected wires much easier.

    Want to work with me?

    Always feel Free to Contact & Hire me

    This week we learnt about microcontrollers boards and how to program them. What is a Microcontroller?¶ A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. You can think of it as a mini central processing unit (CPU). A typical microcontroller includes a processor, memory and input/output (I/O) peripherals on a single chip. AC vs. DC