Skip to content

Embedded programming

Group assignment:

  • Browse your microcontroller’s datasheet
  • Compare performance and development workflows with other architectures click here

Hello everyone! Welcome to our group site. This week, we’ll be exploring the comparison between two AVR families. We’ll be taking a closer look at the ATmega328P from the megaAVR family, a microcontroller widely used in a multitude of electronic projects and the ATtiny44 from the tiny family (The ATtiny44 is a microcontroller from the AVR family, manufactured by Microchip Technology. It is used in a variety of electronic projects to control devices, collect data, and execute programmed tasks).

Functionality comparison

The table below compares two types of microcontroller (MCU). tinyAVR MCUs are specially designed to meet the needs of applications requiring optimum performance, increased energy efficiency and ease of use, all in a compact format. On the other hand, megaAVR MCUs are recommended for designs requiring slightly higher power, particularly suited to applications requiring larger volumes of code.

ATtyni44

Features

Programming of ATtyni with AVR-mec

To program the ATtiny44 with AVR-MEC (Atmel AVR Microcontroller), follow these steps:

  • Step 1 : AVR-mec installing

  • Step 2 : Connectez votre ATtiny44 à votre ordinateur à l’aide d’un programmateur AVR compatible, tel qu’un programmateur ISP (In-System Programmer) ou un programmateur USBASP.

  • Step 3 : Write your program in AVR C or assembly language within the AVR-MEC development environment. You can use the standard AVR libraries and code examples supplied with AVR-MEC to facilitate development.

  • Step 4 : Use AVR-MEC to program your ATtiny44 by downloading the binary file generated during compilation to the microcontroller via the AVR programmer.

  • Step 5 : Once programming is complete, check your application by observing the results on the microcontroller itself, or by connecting external devices such as LEDs, sensors, etc.

ATmega328P

Features

Programming the ATmega328P with the Arduino UNO board

Programming the ATmega328P microcontroller using the Arduino Uno board is a common and straightforward process. Here are the steps to do it:

  1. Setup Arduino IDE: Make sure you have the Arduino IDE (Integrated Development Environment) installed on your computer. You can download it from the official Arduino website and install it following the instructions provided.

  2. Connect Arduino Uno to Computer: Connect your Arduino Uno board to your computer using a USB cable.

  3. Select Board and Port: Open the Arduino IDE. Go to the “Tools” menu and select “Board”. Choose “Arduino Uno” as the board type. Then, go to the “Tools” menu again and select the appropriate port where your Arduino Uno is connected.

  4. Upload Arduino ISP Sketch: You will use the Arduino Uno as an ISP (In-System Programmer) to program the ATmega328P. To do this, upload the ArduinoISP sketch to your Arduino Uno. You can find this sketch in the Arduino IDE under File > Examples > 11. ArduinoISP.

  5. Prepare ATmega328P: Insert the ATmega328P microcontroller into the appropriate socket on the Arduino Uno board. Make sure to align the pins correctly.

  6. Set Programmer: Go to the Tools menu in Arduino IDE, select Programmer, and choose Arduino as ISP.

  7. Upload Code: Write or open the code you want to upload to the ATmega328P in the Arduino IDE. Make sure to select Arduino Uno as the board type and the appropriate port. Then, click on Upload Using Programmer under the Sketch menu.

Programming the ESP32 card

we are going to program a NodeMCU

We’ll just make the LED on the board flash.

  • open your IDE > File > Examples > Basics > Blink . this path will give you a basic code for making an LED blink

  • Declare a variable on pin 2 of the ESP32

  • download the following code onto your ESP32 card
const int LED_BUILTIN = 2;
// 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(500);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(500);                      // wait for a second
}

to install the ESP32 package in the Arduino IDE, click on the link. all the documentation is given there

Programming the Arduino card

The Arduino Nano is a model-compatible open source microcontroller board based on the Microchip ATmega328P microcontroller (MCU).

To keep things simple, we’re going to test this card by making a buzzer sound. The wiring diagram is below.

  • In the IDE, select as board in the board manager Arduino nano.

  • enter the following code
const int BuzzerPin = 5;
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(BuzzerPin, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  tone(BuzzerPin, 1000, 200);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a second
  noTone(BuzzerPin);   // turn the LED off by making the voltage LOW
  delay(500);                      // wait for a second
}

Code

Code buzzer

Code blink