BTE1522 DRE2213 – Week 6 Pi Pico – Digital Input Output

 

Today’s Raspberry Pi class focused on hands-on exercises using the UMPSA STEM Cube, a picosatellite powered by a Raspberry Pi Pico. Students completed Activities 1, 2, and 3, where they explored digital output and input by turning LEDs on and off, blinking them, and reading inputs from switches and sliders.

The objective of these activities is to transition students from learning Python in a simulated environment, where they developed a slider game, to implementing Python in physical computing. Through the exercises, students practiced applying delay functions, making circuit connections, and importing MicroPython libraries into the Thonny IDE. The UMPSA STEM Cube serves as an introductory picosatellite equipped with basic sensors, providing a practical platform for students to apply their knowledge in physical computing.

 

DRE2213

 

BTE1522

BTE1522 DRE2213 – Week 6 Assignment Progress

Well done everyone for your progress in completing your Assignment.

Assignment Gallery Walk on Slider Game Modifications

In today’s class, each group took part in a gallery walk where you showcased your progress on the assignment of modifying the slider game. This interactive session allowed each group to present their unique game modifications and learn from their classmates. Every group, composed of three students, was assigned a unique title that guided specific aspects of their game’s development.

Python Concepts Covered

Through this assignment, you have applied several Python programming concepts, including:

  • Control Statements
    • Utilizing if, for, and while statements to create game dynamics and interactions.
  • Data Handling
    • Managing and updating game data, such as player scores and item positions, in real-time.
  • Data Types
    • Leveraging various data types like integers for scores, lists for storing object positions, and strings for in-game messages.
  • Functions and Modularity
    • Structuring code into functions for better organization and reusability.
  • Error Handling
    • Implementing try and except blocks to manage unexpected inputs or errors gracefully.

Kudos to everyone for their hard work and creativity!

Please submit your assignment report in KALAM. Upload the following:-

  1. Python codes
  2. Youtube links
  3. Assignment reports

 

DRE2213

ARIF FAHMI RE23320 HAZIQ RE23120 AIMAN RE23163
Danieal RE23281 Mahi RE23174 Izdihar RE23392
Izzat RE23157 Aizad RE23147 Lutfy RE23161

RAJA RE23313, SKANTHANESSH RE23028, ARIFF DANIEL RE22197

RE23297 Choo RE23057 Fong RE23294 Zunaizah

BTE1522

BTE1522 DRE2213 – Week 5 Global Classroom

In the latest session of the Global Classroom Initiative for DRE2213 Programming and Data Structure and BTE1522 Innovation (Python Programming) students were privileged to attend a talk by Prof. Ansgar Meroth from Helbron University. Prof. Ansgar delivered a comprehensive overview of IoT networks, particularly as applied to agriculture. This talk aligned perfectly with our BTE1522 and DRE2213 course’s focus, as students in the DRE course gain hands-on experience in Python programming, Raspberry Pi programming, and embedded systems.

Prof. Ansgar’s lecture began with the foundational elements of IoT, including sensors, network architecture, and the various considerations in building robust IoT solutions. Moving deeper, he shared insights on the types of sensors used, architecture design choices, and a project demonstration from his own classes. The talk’s focus on agricultural IoT applications illustrated the immense potential of these technologies to transform farming through precision monitoring and automation.

Key Points Covered in the Session

  1. Overview of IoT Systems
    • Prof. Ansgar began with an introduction to IoT, discussing its growth and role in various sectors, especially in agriculture.
  2. Sensors and Embedded Systems
    • He highlighted the importance of selecting appropriate sensors and embedded devices, considering factors like power consumption, accuracy, and environmental durability.
  3. Network Architecture
    • Prof. Ansgar explained the architecture of IoT networks, emphasizing the role of gateways, cloud systems, and edge devices in enabling data processing and analysis closer to the source.
  4. Class Project Showcase
    • Prof. Ansgar concluded with a detailed example of an agricultural IoT project from his own students, demonstrating the integration of real-time monitoring and data analysis to optimize resource use in farming.

Q&A Session with Prof. Ansgar

The session concluded with an engaging Q&A, where Prof. A addressed various thoughtful questions from students, demonstrating his deep expertise and providing practical guidance. Here are some of the key questions asked and the responses-

1. What are the critical components in developing a reliable and quality IoT solution?

There is a critical need for high-quality sensors, a robust network architecture, and efficient data handling techniques. Reliability can often hinge on the durability of sensors in harsh environments, as well as on efficient protocols for data transmission.

2. What are the considerations for choosing the right sensor in IoT solutions if cost isn’t an issue?

Prioritizing sensor accuracy, durability, and compatibility with other IoT components are recommended. Environmental factors, such as weather and soil conditions, also play a role in sensor selection for agricultural applications.

3. How can we optimize performance in IoT systems with limited power on Raspberry Pi?

Sleep modes and power-efficient protocols, such as MQTT, which is designed for minimal data transfer could be considered. Edge processing can also reduce energy usage by minimizing the amount of data sent to the cloud.

4. How do you ensure reliable data transmission and handling in IoT systems that operate on edge devices?

Using reliable networking protocols and setting up redundant systems to handle transmission errors is a good option, especially in remote areas where network stability may be an issue.

Additional Questions from the Class

1. What is the difference between IoT and IIoT?

While IoT focuses on general applications (e.g., smart homes, agriculture), Industrial IoT (IIoT) emphasizes industrial and manufacturing applications, where the systems must adhere to stringent standards for reliability and security.

2. In hazardous environments, what role does IoT play in monitoring and managing assets safely, and how reliable are these systems?

IoT can monitor environmental conditions and equipment status in real-time, alerting managers to unsafe conditions instantly. With proper system design, these systems can achieve high reliability.

3. What are the potential environmental benefits of using IoT for precision farming?

IoT enables precision resource management, reducing waste and minimizing environmental impact by providing data-driven insights into irrigation, fertilizer use, and crop health.

4. How can data security and privacy be ensured in an IIoT network?

Security is critical in IIoT, where implementing encryption, secure authentication protocols, and regular system audits could be implemented to mitigate risks.

5. How can organizations ensure a successful IIoT implementation without facing cybersecurity risks?

A layered security approach, including firewalls, intrusion detection systems, and ongoing employee training to protect against cybersecurity threats.

6. Are there devices beyond sensors or GPS that can accomplish tasks within IoT or IIoT?

Actuators and drones as examples of devices that can not only sense but also act on data, allowing IoT systems to respond autonomously to changing conditions.

7. What about the durability of sensors used in IoT farming systems? Are they different in quality or sensitivity compared to similar sensors in everyday devices?

In agricultural IoT, sensors are often designed to be more rugged, with higher sensitivity and protective casings to withstand outdoor environments. These are tailored for extended use in tough conditions, unlike everyday consumer electronics.

 

It was both an honor and an incredible experience to host Prof. Ansgar from Helbron University. His insights into the intersection of IoT, embedded systems, and agriculture were inspiring, providing our students with a glimpse into the future of technology-driven farming. Listening to fellow educators motivates me to creating opportunities for global collaboration and learning. As someone who believes deeply in breaking down barriers in education, I look forward to inviting more professors from around the world.

Engaging with international experts not only enriches our knowledge but also motivates us to strive for higher standards in our projects and activities.

Kudos to the students who actively engaged with Prof. Ansgar and asked thoughtful questions during the session. Their curiosity and commitment to learning demonstrated the high standards they are reaching for, making this session even more impactful.

Thank you, Prof. Ansgar, for sharing your expertise and inspiring us to innovate!

BTE1522 DRE2213 – Week 5 Assignments

This week, students from the BTE 1522 and DRE 2213 courses are given assignment that are designed to develop their programming skills in Python. Each group of three students is tasked with choosing one of the 20 game modification options available and implementing it as a team project. This assignment is all about creativity, problem-solving, and teamwork as students work to modify an existing Python game and showcase their programming concepts.

In this assignment, each group will:

  1. Select a Game Modification
    1. Out of 20 different modification options, each group chooses one that they’ll use to enhance a basic game written in Python.
    2. Modifications can range from adding new features, changing game mechanics, enhancing visuals, to incorporating user-friendly elements.
  2. Implement the Code Changes
    1. Using Python, students will modify the codebase to create the enhancement they selected. As they work through these changes, they’ll encounter new programming concepts, which they can build upon for future projects.
    2. This assignment offers students a chance to solidify their coding skills while adding their creative touch.
  3. Submit the Project Components

Each group will submit:

    1. The modified Python code, clearly commented to explain the changes made.
    2. A written report detailing the modifications, gameplay instructions, and the coding process.
    3. A 3-minute video demonstrating the game, explaining the code changes, and showcasing the impact of the modifications.

Reporting

To complete this assignment, please:

  1. Review the Game’s Base Code
    1. Understand the game’s original code before making any changes.
    2. Each student in the group should be familiar with how the code works to effectively contribute to the modification.
  2. Plan the Modification
    1. After selecting a modification, map out the changes needed.
    2. This could include adding new variables, adjusting functions, or integrating additional modules. Using flowcharts or pseudocode can be especially helpful to visualize how the new feature will work within the existing game structure.
  3. Divide and Conquer
    1. With three members in each group, teamwork will be key!
    2. Students should divide tasks based on each member’s strengths and collaborate to implement the modification efficiently.
  4. Test the Changes
    1. Test the game thoroughly to ensure that the new feature or modification works as intended and doesn’t disrupt existing functionality.
    2. Debugging is an important skill in programming, so encountering and fixing errors will be a valuable part of this process.

Upload these in KALAM (https://kalam.ump.edu.my/)

Showcase and Reflect

As part of the final submission, you are encouraged to be creative with their 3-minute video, which should highlight –

  1. Gameplay
    • Show the modification in action and explain how it enhances the game.
  2. Code Explanation
    • Walk viewers through the code changes made, highlighting key additions and adjustments.
  3. Reflection
    • Share insights into the challenges and learning experiences encountered during the project.

Good luck to all the groups, and I look forward to seeing your creativity come to life in your games!

 

BTE1522 DRE2213 – Week 3 – Control Statements and Functions

Let’s explore learning programming by troubleshooting Codes   😀  – Flags and Scoring Systems in Python

Today’s coding session was all about debugging and enhancing a game we’ve been developing step by step. We dove into Act 4, 5, 6 and 7, focusing on how to fix some key issues in the game logic—specifically how to properly handle scoring during collisions between the player and enemies.

PBL – ‘The Problem’

We already had a working player and enemy system in the game. The player can move left and right, while an enemy drops down from the top of the screen. The challenge was ensuring the player’s score only increased by one upon a collision with the enemy. Instead, the score was skyrocketing with every game frame where the player touched the enemy, adding several points instead of just one.

This type of issue is common when developing games, where collisions can occur over multiple frames. But we only want the score to increment once per collision event. To fix this, we introduced an important concept: the flag.

Introducing Flags in Python

In programming, a flag is a boolean variable (True/False) used to indicate whether a certain condition has been met. For our game, we needed a flag to signal whether a collision between the player and enemy had already occurred. This would prevent the score from increasing continuously while the player and enemy rectangles overlap.

Using a Flag to Control Scoring

Here’s how we used the flag –

  1. Define the flag – We introduced a variable collision_occurred, which is initially set to False. This flag keeps track of whether the collision has already happened.
  2. Check the flag during collision – Every time the game checks for a collision between the player and the enemy, it also checks whether collision_occurred is True or False.
    1. If it’s False and a collision happens, the score increments by 1, and the flag is set to True. This prevents further increments until the enemy resets.
    2. If the flag is True, no further points are added, even if the player remains in contact with the enemy.
  3. Reset the flag – Once the enemy moves off-screen and reappears at the top, the flag is reset to False, allowing for another score increment during the next collision.

p/s Score Board is being implemented this year. One of the ways to monitor students progress in class

BTE1522

DRE2213

BTE1522 DRE2213 – Week 2 – Data Types and Control Statements

In Week 2 of the BTE1522 DRE2213 course, the focus was on fundamental programming concepts, specifically data types and control statements in Python. These are critical building blocks for developing logical structures within any programming language and are key to enabling students to design functional applications.

  1. Data Types in Python
    Understanding the various data types is essential in programming. Python offers several data types that students learned to apply during the class –

    • Integers (int): Whole numbers, like 1, 2, or 100.
    • Floating-point numbers (float): Numbers with decimal points, like 3.14 or 5.0.
    • Strings (str): Text data, enclosed in quotes, like “Hello, World!”.
    • Booleans (bool): True or False values, used for conditional logic.
    • Lists and Tuples: Students were introduced to lists, which are mutable sequences, and tuples, which are immutable sequences, to store multiple values.
  2. Control Statements in Python
    Control flow structures help in decision-making and looping through tasks. The students explored:

    • If, Elif, and Else Statements: Conditional statements that allow the program to execute specific blocks of code based on certain conditions.
    • While and For Loops: Used to repeat a block of code while a condition holds true.

Activity 1-3: Player Creation and Movement

Students applied their understanding of data types and control statements through practical coding exercises. In Activities 1-3, they created a basic player character and programmed its movement across the game window.

The coding exercise allowed students to implement:

  • Variables to define the player’s position, size, and color.
  • Control statements like if-elif-else to determine how the player moves in response to keyboard input.
  • Basic boundary control to prevent the player from moving off-screen.

Moving to the Second Phase – Five Challenges

After completing the initial activities, students moved to a more challenging phase involving code modifications and analysis. They were tasked with modifying and analyzing code to address five distinct challenges, each designed to deepen their understanding of data types and control statements.

Challenge 1: Modify Movement with Control Statements

Objective – Students were introduced to control statements such as if, elif, and else. They modified the code to allow the player to move based on specific conditions, such as different key presses resulting in different player actions.

Challenge 2: Boundary Control with Conditional Statements

Objective – In this challenge, students explored boundary detection using if and else statements. The goal was to prevent the player from moving outside the game window. This reinforced their understanding of how conditions can control flow in a program.

Challenge 3: Change Player’s Color with Data Types

Objective – Students were introduced to the concept of variables and data types such as lists and tuples. The challenge was to change the player’s color based on certain conditions, like the player reaching specific coordinates.

Challenge 4: Score and Time Tracking with Variables

Objective – Students explored the use of variables and loops to add a scoring system and time limit. They learned how to create a variable that increments when the player performs specific actions and how to manage game time using a while loop.

Challenge 5: Advanced Activity: Collision Detection

Objective – The final challenge involved practicing control structures and Boolean data types to detect when the player collided with the screen edges. This challenge required students to think critically about game dynamics and how to implement collision logic.

Pedagogical Approaches in the Exercise

To ensure a thorough understanding, two pedagogical approaches were used throughout the five challenges:

  1. Code Modification/Generation
    Students in DRE2213 were required to actively modify their existing code based on the challenge descriptions. This hands-on approach allowed them to understand the logic behind each task and improve their problem-solving skills by directly interacting with the code.
  2. Code Analysis
    In BTE1522, students were provided with completed code and asked to map it to the challenge objectives. This method allowed them to break down complex code structures, understand how different components work together, and link theoretical concepts to real-world applications.

Week 2 was an essential part of the course as it introduced fundamental programming concepts like data types and control statements in Python. Through interactive activities and challenges, students not only learned to implement these concepts but also developed problem-solving skills by engaging in code modification and analysis. These exercises laid a strong foundation for the more advanced topics to come in the course.

Nurul Oct 15th

DRE2213   

 

BTE1522

Artificial Intelligence – Python Programming – Train the Trainers Workshop

A 4-days workshop crafted for academicians from Polytechnics Malaysia.

I recently conducted a comprehensive 4-day workshop to introduce participants (among academicians from Polytechnics in Malaysia) to both fundamental and advanced topics, offering hands-on activities that showcased the powerful applications of AI, electronics, and programming.

Thank you Pn Azlyn for coordinating the communication and facilitating the process :).

Below is a summary of the activities we conducted over the course of this workshop.

Day 1  Foundations of AI, Python, and Raspberry Pi
The workshop kicked off with an introduction to AI and the Raspberry Pi microprocessor. We started with a fun ice-breaker activity, Introduction BINGO, where participants got to know each other. Afterward, we delved into the fundamental concepts of hardware and electronic components, ensuring everyone was comfortable with the physical aspects of working with a Raspberry Pi.

Key Topics Covered –

  1. Hardware & Electronic Components – Understanding the basics of the Raspberry Pi, GPIO pins, and essential sensors.
  2. Raspberry Pi Microprocessor – Overview of how Raspberry Pi works and its applications in AI.
    This foundational day set the stage for the deeper dives into programming and hardware control that were to follow.

Day 2 Control Statements, Communication, and Sensors

We began Day 2 by introducing participants to Python control statements, providing the backbone for controlling the hardware components with Python scripts. This session included practical activities focused on various communication protocols like I2C and SPI, commonly used for sensor integration.

Key Activities and Topics –

  1. Python Control Statement – Introducing loops, conditions, and their use in hardware control.
  2. Communication Protocols – Learning how Raspberry Pi communicates with sensors using I2C and SPI.

Hands-on Activities –

  1. Act 1, 2 – LED ON and OFF Control – Participants learned to turn LEDs on and off using Python.
  2. Act 3 – LED Blinking – Adding logic to make LEDs blink at intervals.
  3. Act 4 – Keyboard Control – Using the keyboard to interact with hardware components like LEDs.
  4. Act 5 – OLED Display -We explored controlling an OLED display using Python libraries and the I2C protocol. This included displaying text and graphics, which captivated participants, demonstrating the versatility of the Raspberry Pi as an interface device.

Day 3 Exploring Sensors and Camera Controls

On Day 3, we moved into more complex sensor and camera integration. Participants worked hands-on with various sensors to collect and process real-world data.

Key Sensors Covered –

  1. Act 6 – I2C Accelerometer: Using accelerometers to measure movement and tilt.
  2. Act 7 – Ultrasonic Sensor: Measuring distances using ultrasonic waves.
    We also explored using the camera with the Raspberry Pi
  3. Act 8 – Camera / Image: Capturing still images and processing them.
  4. Act 9 – Video Streaming: Streaming live video using the Raspberry Pi camera, giving participants a look at real-time image processing.
    We ended the day by learning how to remotely control the Raspberry Pi using SSH Scripting for headless setups.
    Day 4: Advanced Camera Control and Project Development
    The final day was packed with creative development. Participants were introduced to more advanced concepts of camera control using Python and integrating this control into group projects.

Key Highlights

  1. Camera Control & Geany – Using Geany, a lightweight integrated development environment (IDE), to control cameras with custom scripts.
  2. Project Development – Each group was tasked with designing and developing a project, incorporating the skills learned over the past three days. The projects ranged from simple security systems to advanced sensor networks.
    1. Participants also learned how to set up their Raspberry Pi in Headless Mode, using SSH to control it without a dedicated monitor or keyboard.
    2. Project Presentation and Way Forward
    3. After completing their group projects, participants presented their creations, showcasing the applications of Python programming, sensors, and AI-based hardware control. The final session was a recap of the key concepts, where participants were encouraged to continue exploring AI and Raspberry Pi on their own. They also completed a Post-Test to measure their progress throughout the course.

Looking Forward
This workshop is just the beginning. The potential of Raspberry Pi combined with Python programming offers limitless possibilities, from creating AI-powered projects to building real-world applications. Participants left equipped with the skills and confidence to continue their journey in AI and embedded systems development.

Conclusion
In just four days, participants transitioned from having no experience with Raspberry Pi or Python to developing their own AI-based projects. This course laid a strong foundation for understanding hardware, software, and AI in a hands-on, engaging way. The combination of sensors, control statements, and camera-based projects showcased the immense power of integrating AI and Python with Raspberry Pi.

Stay tuned for more workshops that push the boundaries of AI and embedded programming!

I hope everyone had enjoyed the course as much as I did in facilitating it.

Nurul (Oct 3rd, 2024)

Day 4

Day 3

 

Day 2

Day 1

Misc