Week 4 - Exploring Embedded Architecture, toolchains and development workflows¶
XIAO RP2040 Development Board¶
XIAO RP2040 with Micropython¶
HARDWARE SETUP
- XIAO RP2040
- type-C cable
- PC
SOFTWARE SETUP
We followed seed studio wiki for software setup
https://wiki.seeedstudio.com/XIAO-RP2040-with-MicroPython/#introduction-of-micropython
Thonny is a free development program for PC that was made by an independent dev who goes by the same name. It is an open-source integrated development environment (IDE) that can be used to create various applications using the Python programming language. Downloaded Thonny.
After installation, open thonny. Tools→ Options to open settings. Chose the “Interpreter” interface and select the device as “MicroPython(Raspberry Pi Pico)” and the port as “Try to detect prot automatically”. Press and hold the “BOOT” button and then connect the Seeed Studio XIAO RP2040 to the PC through the Type-C cable. Click Install or update MicroPython.
In variant choose Raspberry Pi. Pico/Pico H and click install
A test code was given. If the code works well, the led turns off and on once a second.
And it worked.
The top pane can be used to write programs or scripts. the bottom pane gives us access to the live interpreter.
XIAO RP2040 with Arduino IDE¶
We can also program the RP2040 through Arduino IDE. First step is to download the latest version:
After installing the latest version look for documentation from Seeed Studio.
It will instruct you how to install the RP2040 Board package to interface with the microcontroller.
Next in the Arduino IDE go to Files→Examples, and select “Blink”. Verify and Upload.
Almost there! To run “blink” it is required to specify which partifular RP2040 board is used.
Now we are changing the time between (red) blinks to verify that we have programming control.
Now we test the other two built-in LEDs (green and blue color) to ensure they also work.
And it works! Mission accomplished:
ATTINY 1614¶
Objective- demonstrate and compare the toolchains and development workflows for available embedded architectures for ATTiny1614
The link to official datasheet for ATTiny 1614 has been attached here
Information about some peripherals
ATtiny1614 | |
---|---|
Pins | 14 |
SRAM | 2KB |
Flash | 16KB |
EEPROM | 256B |
Max. frequency | 20 MHz |
USART | 1 |
TWI (I$^2$C) | 1 |
SPI | 1 |
ADC | 2 |
The Key Features of the ATtiny1614 are the following:
- Uses an AVR CPU - The AVR CPU is an example of the Harvard CPU architecture that seperates memory storage and buses (set of physical connections like cables, circuits, ec. that can be shared by multiple hardware systems for communications. Read more here: https://www.geeksforgeeks.org/what-is-a-computer-bus/) for instructions and data.
- The AVR CPU can run upto 20 MHz
- 2KB SRAM for storing data that is erased when powered off.
- 256 bytes EEPROM for storing memory even when power is turned off.
-
14 pins available (in the 14 pin SOIC package available here)
Source: Official Datasheet for ATtiny1614/1616/1617
- There are 12 pins (PA0-PA7, PB0-PB3) are programmable GPIO pins that accept digital input and send out digital output.
- In addition, all of them except 2 (PB2 and PB3) can also accept analogue input.
- PA0 is also used to connect to UPDI tool for programming and debugging.
- Can communicate using USART (an advanced version of UART), SPI, TWI (Two Wire Interface; this bus is identical to I²C, the name TWI was introduced by Atmel and other companies to avoid trademark related conflicts related to I²C)
- Has an internal Analog to Digital (ADC) Converter to convert analog signals (signals sent in a waveform) to digital signals (binary signals; 0 & 1)
Programming/debugging protocols¶
When we get an ATtiny 1614 from the factory, it has no memory, so it cannot fetch any instructions for what to do. We need to write our code into the memory, for which we need a low-level protocol that can transfer data from our computer to the microchip. Different chip families use different protocols. The ATtiny uses a UPDI protocol
UPDI (Unified Programming Debugging Interface): is an Atmel/Microchip proprietery programming protocol. It is the default programming mode for the newer AVRs including the ATTiny1614 chips and uses only one pin. It uses a serial-to-USB converter which comes in three types, an off the shelf serial-to-USB converter, an FTDI cable, or a FAB FTDI board. For more information, read https://mtm.cba.mit.edu/2021/2021-10_microcontroller-primer/.
Toolchain¶
Toolchain is any sequence of tools that we use to transfer instructions from us to the microcontroller
Device | Compiler | Protocol/Link | Device: Programmer | Protocol/Link | Device: Microcontroller |
---|---|---|---|---|---|
Personal computer | Arduino IDE | UPDI | Serial-to-USB converter | over TTL link | ATTiny1614 |
Serial Communication¶
TTL - Transistor-Transistor Logic is a type of digital logic circuit that is used in a type of serial communication called TTL serial communication.
Programmer: USB - UPDI converter¶
Programming the ATtiny1614 using the Arduino IDE¶
- Open Arduino IDE > Files> Preferences > Click on icon at the side of text field> Copy and paste board manager URL
- Once package has been downloaded > Go to Tools>Board Manager>Type ‘MegaTiny Core’>Install.
- According to the instructions, once done, I should be able to view your board in board manager options. Once I connect the microcontroller to the serial connector and my computer, I should be able to choose the correct board, and choose programmer as Serial-UPDI with Slow 57600 baud. You should be able to program from the Arduino IDE.
- But I am getting this error showing that the index could not be updated.
-
When I consulted with my instructor, I was told that this link was broken and gave me a new link to copy and paste:
https://saheenpalayi.github.io/Megatinycore-libs/package/package_drazzy.com_index.json
- Since we have not made any boards yet. I used boards that our instructor already had on hand. I connected the Fab FTDI Board to the FTDI to UPDI converter which is then connected to the board containing the ATtiny1614 microprocessor. Connect the USB cable to the computer to start programming.
- Then choose the correct Board and Port.
- Choose the correct Programmer (SerialUPDI - SLOW 57600 baud) and the Chip to ATtiny1614. Now you are ready to program on the microprocessor.
- I tried to program a basic Blink program using the onboard LED connected to PA3 of the chip. Using the pin mapping diagram shown below, I see that I have to program it as pin 10 in the Arduino IDE.
- While uploading, upload using the programmer (Ctrl+Shift+U)
- The code should work. Here is a video of the LED blinking using an ATtiny1614
Here is the code I used for the same:
#define LED 10
void setup(){
pinMode(LED,OUTPUT);
}
void loop(){
digitalWrite(LED,HIGH);
delay(1000);
digitalWrite(LED,LOW);
delay(1000);
}
ATtiny84¶
The chip we used is ATtiny84. It is an 8-bitbAVR Microcontroller with 8K Bytes In-System Programmable Flash. Datasheet.
Specifications¶
Features | Details |
---|---|
Architecture | 8-bit AVR RISC |
Flash Memory | 8 KB |
Clock Speed | : 0 - 8MHz at 2.7 - 5.5V, 0 - 16MHz at 4.5 - 5.5V |
GPIO Pins | 14 |
Peripherals | USART, SPI, I²C (TWI), External Interrupts |
Operating Voltage | 2.7 - 5.5V |
Programming Interface | ISP (In-System Programming) via SPI |
Pin Configurations¶
Block Diagram of the AVR Architecture¶
AVR Toolchain¶
The AVR Toolchain is a collection of software tools used to develop applications for AVR microcontrollers (such as ATmega and ATtiny series). It enables compiling, assembling, linking, debugging, and flashing programs onto AVR-based devices
Components of the AVR Toolchain
- AVR-GCC– Compiles C/C++ code for AVR.
- AVR Binutils – Assembler (
avr-as
), linker (avr-ld
), and object file tools. - AVR Libc – Standard C library optimized for AVR microcontrollers.
- AVRDUDE – Tool for flashing programs onto AVR chips.
- GDB (GNU Debugger) for AVR – Debugging tool.
- Make (Optional) – Automates build processes using Makefiles.
ChatGPT promt: what is AVR tool chain
Programming¶
Our Instructor Saheen already made a PCB with ATtiny84. He gave that PCB for try out the programming. For programming the board, we used the AVR for windows which Saheen made. I downloaded it from Saheen’s github and extracted the file and opened it on VS Code.
There is already a code preloaded in the AVR for Windows and I tried to flash that code into ATtiny84. The function of the program is to turn on the LED on the PCB while we press the button.
We can’t directly program the ATtiny84 using our PC. A programmer is needed for flashing the program. So we used Fabtiny-isp which is already available in the lab for programming the ATtiny84.
I tried to flash the program to the ATtiny84 and got failed multiple times. I refered many documentations and I couldn’t able to find the steps to flash it using windows. The documentations are mainly for Linux/Mac were only available. So I consulted Saheen and he told me to try flash after installing Adafruit_Windows_Drivers in my pc.
Initially The code is converted into hex code using the command “./hex.bat”.
Then flash the code into ATtiny84 using the command “./flash.bat”.
Output¶
ESP32¶
SP32
- What it is:
- ESP32 is a microcontroller series known for having integrated Wi-Fi and Bluetooth capabilities. It’s made by Espressif Systems.
- Key features and benefits:
- Wireless connectivity: Built-in Wi-Fi and Bluetooth.
- Dual-core processor: Most ESP32 chips have a dual-core processor, allowing for multitasking.
- Low cost: Typically inexpensive.
- Versatile: Suitable for a wide range of projects, especially those related to IoT (Internet of Things).
- Good for radios
- Where ESP32 excels:
- IoT projects: Connecting sensors and devices to the internet.
- Wireless audio streaming: Creating Bluetooth speakers or audio receivers.
- Home automation: Building smart home devices controlled via Wi-Fi.
Processing Power¶
ESP32 outperforms AVR and RP2040 in terms of processing power:
- ESP32: Dual-core processor with a clock speed of up to 240 MHz3
- RP2040: Dual-core processor with a maximum clock speed of 133 MHz3
- AVR: Single-core processors with clock speeds typically below 20 MHz
- ARM: Varies widely, but many ARM cores can match or exceed ESP32’s performance
Memory Capacity¶
ESP32 generally offers more memory than AVR and RP2040:
- ESP32: 520KB SRAM and 4MB flash memory34
- RP2040: 264KB SRAM3
- AVR: Typically less than 8KB SRAM and 256KB flash
- ARM: Varies, but can match or exceed ESP32’s capacity in some models
Built-in Peripherals¶
ESP32 stands out with its integrated wireless capabilities:
- ESP32: Built-in Wi-Fi and Bluetooth6
- RP2040: No built-in wireless connectivity
- AVR: Limited built-in peripherals
- ARM: Varies, but often requires external chips for wireless connectivity
Power Consumption¶
Power consumption varies depending on the operating mode:
- ESP32:
- Awake: 52.6-64.6 mA
- Light Sleep: 1.6-13.8 mA
- Deep Sleep: 0.012-9.4 mA5
- RP2040: Generally lower power consumption than ESP326
- AVR: Very low power consumption, often in the microamp range
- ARM: Varies, but can be very power-efficient in sleep modes
Cost¶
ESP32 is generally more cost-effective when considering its features:
- ESP32: Relatively low-cost considering its capabilities
- RP2040: Very cost-effective
- AVR: Low-cost options available
Target Boards and Toolchains¶
-
ARM: Wide range of prices, from very low to high-end
Different target boards based on these processors can be programmed using various toolchains:
- Arduino IDE: Supports ESP32, RP2040, AVR, and some SAMD boards37
- PlatformIO: Supports multiple platforms and provides a unified development environment
- Espressif IDF: Specifically for ESP32 development
- ARM Mbed OS: For ARM-based processors like SAMD and RP2040
- AVR-GCC: Specifically for AVR microcontrollers
Step 1: Install PlatformIO IDE Extension in Visual Studio Code¶
- Open Visual Studio Code (VS Code): Launch your VS Code application.
- Open the Extensions Marketplace:
- Click on the Extensions icon in the Activity Bar on the side of the window (it looks like a square made of smaller squares).
- Alternatively, use the keyboard shortcut
Ctrl+Shift+X
(orCmd+Shift+X
on macOS).
- Search for PlatformIO: In the Extensions Marketplace search bar, type “PlatformIO”.
- Install the PlatformIO IDE: Find the “PlatformIO IDE” extension (usually the top result, published by PlatformIO) and click the “Install” button.
- Wait for Installation: VS Code will download and install the PlatformIO IDE extension. This might take a few minutes depending on your internet connection.
- Restart VS Code (If prompted): After installation, VS Code may prompt you to restart the editor. If so, click “Restart” to ensure the extension is properly loaded.
Step 2: Create a New PlatformIO Project for ESP32¶
- Open PlatformIO Home:
- After installing PlatformIO, you should see a PlatformIO icon in the Activity Bar. Click it to open the PlatformIO Home screen.
- If you don’t see the icon, you can also access PlatformIO Home via the VS Code command palette:
Ctrl+Shift+P
(orCmd+Shift+P
on macOS), then type “PlatformIO: Home” and select it.
- Create New Project: On the PlatformIO Home screen, click the “New Project” button.
- Project Wizard: The New Project wizard will appear.
- Name: Enter a name for your project (e.g., “ESP32Blink”).
-
Board: This is a crucial step. Type “ESP32” into the board search box. A list of ESP32 development boards will appear.
- Identify Your Specific ESP32 Board: Determine the exact model of your ESP32 board (e.g., “ESP32 Dev Module”, “NodeMCU-32S”, “Adafruit ESP32 Feather”). Look for this information printed on the board itself.
- THE BELOW ONE IS OUR
``` platform = espressif32 board = upesy_wroom framework = arduino upload_speed = 115200 upload_port = COM9
```
- Select Your Board: Choose the correct ESP32 board from the list. If you’re unsure, “ESP32 Dev Module” is a common generic option.
- Framework: Select “Arduino” as the framework. This allows you to use the familiar Arduino programming environment and libraries.
- Location (Optional): You can change the default project location if desired.
- Click “Finish”: PlatformIO will create the project structure, download necessary libraries, and set up the environment.
STEP 3: INSTALL DRIVER TO YOUR LAPTOP.¶
CP210x USB to UART Bridge VCP Drivers - Silicon Labs . CLICK HERE TO GO TO WEBPAGE
After extraction, right-click silabser.inf and click Install. Once the driver is installed, open Device Manager through the Windows search panel. Navigate to Ports to verify the installation and check the port name.
Step 3: Configure Project Settings for Your Specific ESP32 Board¶
platform = espressif32
board = upesy_wroom
framework = arduino
upload_speed = 115200
upload_port = COM9
Important Considerations:
- Board Identification: Accurately identifying your ESP32 board is essential. Using the wrong board setting in
platformio.ini
can lead to compilation or upload errors. - Serial Monitor Baud Rate: The
monitor_speed
setting determines the communication speed between your ESP32 and the serial monitor. Make sure this matches the baud rate used in your code (usually in theSerial.begin()
function).
Example: Blinking LED Code
In the src
directory of your PlatformIO project, create or modify the main.cpp
file with the following basic “Blink” sketch:
Run this code and then write this code and the led will start blinking.
the difference in toolchain are
Key Findings¶
- Processing Power: ESP32 offers the highest clock speed (240 MHz), followed by RP2040 (133 MHz). AVR processors are typically slower14.
- Memory: ESP32 provides the most on-chip memory, while RP2040 offers extensive off-chip flash support1.
- Wireless Connectivity: ESP32 stands out with built-in Wi-Fi and Bluetooth, which the others lack14.
- Power Consumption: AVR and SAMD processors generally have lower power consumption, especially in sleep modes. ESP32 has good power management features despite its higher performance4.
- GPIO and Peripherals: ESP32 offers the most GPIO pins and a wide range of built-in peripherals16.
- Cost: RP2040 is very cost-effective, while ESP32 offers good value considering its features1.
- Development Ecosystem: All processors have good support in terms of development tools and libraries, with Arduino IDE being a common platform for hobbyists37.
-
Applications: ESP32 is ideal for IoT and wireless projects, RP2040 for cost-sensitive real-time applications, AVR for simple, low-power devices, and SAMD for a balance of performance and power efficiency1.
-
Chip: ESP32 is a single 2.4 GHz Wi-Fi and Bluetooth combo chip. The ESP32 series includes several models such as ESP32-D0WD-V3, ESP32-D0WDR2-V3, ESP32-U4WDH, ESP32-S0WD, ESP32-D0WDQ6-V3, ESP32-D0WD and ESP32-D0WDQ6.
- Speed: Up to 240 MHz (160 MHz for ESP32-S0WD).
- Memory:
- 448 KB of ROM.
- 520 KB of SRAM.
- 16 KB of SRAM in RTC.
- External QSPI Flash/SRAM: Up to 4 x 16 MBytes. Some ESP32 models have in-package flash or PSRAM. For example, ESP32-U4WDH has 4 MB of flash. ESP32-D0WDR2-V3 has 2MB PSRAM.
- GPIO Pins: 34 programmable GPIOs. Some GPIO pins have restrictions and are input-only.
- Analog Pins: The ESP32 integrates 12-bit SAR ADCs supporting measurements on 18 channels (analog-enabled pins). It also has two 8-bit DAC channels.
- Communication Protocols:
- UART.
- SPI.
- I2C.
- I2S.
- SDIO.
- Ethernet MAC interface.
- TWAI® (compatible with ISO 11898-1, CAN Specification 2.0).
- RMT (TX/RX).
- ADC: Yes, the ESP32 integrates two 12-bit SAR ADCs.
- Voltage Requirement for Microcontroller: 2.2 V to 3.6 V.
- Logic Voltage: Varies depending on the power domain. The I/O supply voltage (VIO) can be 1.8 V or 3.3 V.
- GPIO Output Voltage and Current:
- High-level output voltage (VOH): 0.8 x VDD1.
- Low-level output voltage (VOL): 0.1 x VDD1.
- High-level source current (IOH):
- VDD3P3_CPU power domain: 40 mA.
- VDD3P3_RTC power domain: 40 mA.
- VDD_SDIO power domain: 20 mA.
- Low-level sink current (IOL): 28 mA.
- Maximum drive capability (IMAX): 12 mA.
- Cumulative IO output current: 1200 mA.
STM32F303 Nucleo¶
The ARDUINO® Uno V3 connectivity support and the ST morpho headers allow the easy expansion of the functionality of the STM32 Nucleo open development platform with a wide choice of specialized shields.
The STM32 Nucleo-64 board does not require any separate probe as it integrates the ST-LINK debugger/programmer.
The STM32 Nucleo-64 board comes with the STM32 comprehensive free software libraries and examples available with the STM32Cube MCU Package.
Toolchains & Development Environments¶
- STM32CubeIDE (Official IDE from ST)
- Keil µVision (Popular for ARM development)
- IAR Embedded Workbench (Commercial, optimized compiler)
- PlatformIO with VS Code (Flexible and modern development workflow)
- Arduino IDE (For quick prototyping, but limited advanced debugging)
Comparing Workflows¶
- Programming Languages: STM32 supports C, C++, and MicroPython (via STM32Cube or custom firmware).
- Compilers: GCC (via ARM toolchain), Keil, IAR.
- Debugging Options: ST-Link debugger (onboard), OpenOCD, or J-Link.
- Flashing Methods: USB DFU, ST-Link, Serial Bootloader.
Programming STM32F303 Nucleo with Arduino IDE¶
Hardware:¶
- Board: STM32F303 Nucleo
- Onboard Debugger: ST-Link (SWD interface)
- Connectivity: USB (for power, serial communication, and flashing)
Software:¶
Component | Purpose |
---|---|
Arduino IDE | Writing and compiling code |
STM32duino Core | Arduino framework for STM32 |
ST-Link Drivers | Interface between PC and STM32 Nucleo |
GCC ARM Compiler | Compiles the C/C++ code |
Uploader (ST-Link, DFU, or Serial) | Uploads firmware to the board |
Drivers & Libraries:¶
- ST-Link Drivers: I downloaded the drivers for ST-Link
- Arduino STM32 Core: Provides Arduino API compatibility for STM32 boards.
I followed the following tutorial to install the board in Arduino IDE
https://github.com/stm32duino/Arduino_Core_STM32/wiki/Getting-Started
Setup the Environment¶
- Install Arduino IDE (latest version).
-
Add the STM32 Board Support Package:
- Open File → Preferences
-
Add this URL to “Additional Board Manager URLs”
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
-
Download the board in the board manager after adding the board.
- Selecting the board
The Board must be selected from the STM32 MCU Based Boards. I am using Nucleo-64 based on STM32F303RE.
The board must be specifically selected from the Board part number
The upload method must be selected according to your need. i am using a STM32CubeProgrammer. The STM32 Cube Programmer can be downloaded from this link
The Blink example can be uploaded to the board. The board was faulty, therefore the code couldn’t be uploaded successfuly.
Raspberry pi¶
A Raspberry Pi is a small, affordable, single-board computer developed by the Raspberry Pi Foundation in the UK. It was originally designed to promote the teaching of basic computer science and programming in schools, but it has since become a popular tool for hobbyists, makers, and professionals. The device is about the size of a credit card and typically costs between 5and5and75, depending on the model. Despite its compact size and low cost, it is highly versatile and capable of performing a wide range of tasks, from running simple programs to powering complex projects.
One of the key features of the Raspberry Pi is its GPIO (General Purpose Input/Output) pins, which allow users to connect and control external hardware such as sensors, LEDs, and motors. This makes it an excellent choice for electronics projects, robotics, and Internet of Things (IoT) applications. Additionally, the Raspberry Pi supports various operating systems, including Raspberry Pi OS (based on Debian Linux), Ubuntu, and even Windows IoT Core, providing flexibility for different use cases.
Pi OS Installation¶
First, make sure you have everything you need: a Raspberry Pi board, a microSD card (8GB or larger), a microSD card reader, a computer with internet access, a power supply for the Raspberry Pi, and optionally, a monitor with an HDMI cable to make the setup easier.
Next, download the Raspberry Pi Imager from the official Raspberry Pi website. This tool is available for Windows, macOS, and Linux, and it’s the easiest way to install the operating system. Once downloaded, install it on your computer.
Link : Raspberry Pi OS – Raspberry Pi
Now, insert your microSD card into your computer using the card reader. If there’s any important data on the card, make sure to back it up, as the installation process will erase everything.
Open the Raspberry Pi Imager on your computer. You’ll see a simple interface with two main options: one to choose the operating system and another to select the storage device. Click on “Choose OS” and pick “Raspberry Pi OS” from the list. You can choose the full version with recommended software, the lite version for a minimal setup, or other specific versions depending on your needs.
After selecting the OS, click on “Choose Storage” and pick your microSD card from the list. Be careful to select the correct device to avoid accidentally erasing something important. Once you’re sure, click “Write” to start the installation. The tool will download the Raspberry Pi OS image (if it hasn’t already) and write it to the microSD card. This might take a few minutes, so be patient.
When the process is complete, safely eject the microSD card from your computer and insert it into the Raspberry Pi’s microSD card slot. Connect your Raspberry Pi to a monitor using an HDMI cable, plug in a keyboard and mouse, and then power it up by connecting the power supply.
The Raspberry Pi will boot up and guide you through the initial setup. You’ll be prompted to set up Wi-Fi, update the system, and configure a few preferences. Just follow the on-screen instructions, and you’ll be good to go.
Once the setup is complete, you’ll have a fully functional Raspberry Pi running Raspberry Pi OS, ready for whatever project you have in mind. It’s a fun and rewarding process, and you’ll be amazed at what this little device can do!
NANO Text editor¶
The nano
text editor is a simple, user-friendly, and command-line-based text editor that comes pre-installed on Raspberry Pi OS (formerly Raspbian). It’s a great tool for editing configuration files, writing scripts, or creating documents directly on your Raspberry Pi without needing a graphical interface.
First I tried using Nano for making my python script but I found it a bit hard hard since it is raw and there are no visual representations for diafiltrating syntax etc. Link : Guide to the nano Text Editor - Pi My Life Up
Geany¶
Geany is a lightweight, fast, and feature-rich text editor that is perfect for programming and general text editing. It’s available on Raspberry Pi OS and is a great alternative to more basic editors like nano
or vim
, especially if you prefer a graphical interface. Geany supports syntax highlighting, code folding, auto-completion, and many other features that make it a favorite among developers.
Link : https://www.notion.so/PI-19978c4997e180a19a0dd8c39e04c646?pvs=4
Blink LED using Micro Python¶
- For my first program I followed an online documentation Link : Making a LED blink using the Raspberry Pi and Python | Raspberry Pi HQ
- First import Pi GPIO library her i have used RPi.GPIO, It is a popular Python library used to control the GPIO (General Purpose Input/Output) pins on a Raspberry Pi. It’s one of the most commonly used libraries for interacting with hardware components like LEDs, buttons, sensors, and motors. Whether you’re a beginner or an experienced maker, RPi.GPIO provides a simple and straightforward way to manage the GPIO pins on your Raspberry Pi.
- Then I imported the sleep function from the time module this allows you to directly use the
sleep()
function from thetime
module without needing to reference thetime
module itself. This makes your code cleaner and easier to read, especially if you’re using thesleep()
function frequently. - And then using the basic syntax to make a basic program, for more syntax refer : MicroPython Documentation
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(26, GPIO.OUT, initial=GPIO.LOW) # Set pin 26 to be an output pin and set initial value to low (off)
while True:
GPIO.output(8, GPIO.HIGH) # Turn on
sleep(2) # Sleep for 2 second
GPIO.output(8, GPIO.LOW) # Turn off
sleep(2) # Sleep for 2 second
References¶
https://mtm.cba.mit.edu/2021/2021-10_microcontroller-primer/tools-updi/
https://mtm.cba.mit.edu/2021/2021-10_microcontroller-primer/fab-arduino/
https://mtm.cba.mit.edu/2021/2021-10_microcontroller-primer/fab-arduino/
https://www.linkedin.com/pulse/what-difference-between-ttl-rs-232-rayming-techonloy-dxh8c/
https://forum.arduino.cc/t/installing-attiny-on-ide-2-2-1-solved/1209766/2
https://www.geeksforgeeks.org/what-is-a-computer-bus/
https://electronics.stackexchange.com/questions/50915/what-is-the-difference-between-i2c-and-twi
https://study.com/academy/lesson/what-are-digital-and-analog-signals-definition-lesson-quiz.html