Learning Outcome

In this chapter, we learn to


Introduction: DC Motor, Relay, and WiFi Access Point.

Activities: Build a smart classroom integrated with gesture sensor, USB relay, DC motor, and OLED.

Bonus: Program the smart classroom to be WiFi enabled and controlled through a web dashboard.

Introduction to DC Motor

In this lesson, we will finally get our hands on a DC motor. This particular invention serves as the cornerstone of automation, converting electric energy into motion. Its a versatile component that can power an array of mechanisms, from spinning wheels to robotics arms. Consider it as a tool that can transform your ideas into reality. Let's get this thing moving!

> Libraries <

-> Libraries: board, time, busio, pwmio, adafruit_motor.

-> DC Motor Configuration:

< CircuitPython Code >

Click here to download code

< Expected Output >

Upon completion of the activity, you should be able to:

-> The program will print the DC motor speed on the shell console.

-> DC Motor will continuously rotates at a different speed and direction starting from reverse direction at 50% (-0.5) to 25% (-0.25), and to a halt at 0%. Then it proceedsto forward direction of 25% (0.25) and 50% (0.5) speed.

-> Each speed will last for 2 second, then the cycle repeats.

Mini Activity DC Motor

From the previous chapter, we have learned how to operate the potentiometer module oon the EDU PICO, now, it is time we make use of that knowledge in this mini-activity. Let's program our EDU PICO to control the DC motor speed using the potentiometer. Sounds simple right? Let's give a try!

> Libraries <

-> Libraries: board, time, AnalogIn, pwmio, adafruit_motor.

-> DC Motor Configuration:

< CircuitPython Code >

Click here to download code

< Expected Output >

Upon completion of the activity, you should be able to:

-> Include neccessary libraries required to function the potentiometer.

-> Initialize the pin used for the potentiometer.

-> The potentiometer sensor can increase and decrease the speed of the motor.

Introduction to Relay

In this lesson, we will learn how to operate the USB relay on the EDU PICO, but more importantly, to understand how a relay works. A relay is an electromechanical device that acts as a switch controlled by an electrical signal. It allows a low-power circuit to control a high-power circuit, making it an essentia component in various electrical and electronic applications. In this case, we will use the EDU PICO to control the ON / OFF of the relay, which will control the ON / OFF of a USB LED light stick connected to the USB port!

> Libraries <

-> Libraries: board, digitalio.

-> USB Relay Configuration:

< CircuitPython Code >

Click here to download code

< Expected Output >

Upon completion of the activity, you should be able to:

-> The program will begin by prompting the user to input either 1 for ON or 0 for OFF at the shell console to control the on and off of USB relay.

-> If the input is 1, the USB relay will turn ON and you will notice the relay LED indicator next to the USB port will light up, indicating the relay is switched ON.

-> If the input is 0, the USB relay will turn OFF.

-> Connect the USB LED light stick to the USB relay to test out the USB relay functionality.

Project- Smart Classroom

In this project, we will learn to integrate ADPS9960 gesture sensor to track student's movement when entering and leaving the room. The goal is to create a smart classroom that optimizes energy usage based on the number of occupants. To achieve that, we will program the relay to turn on and off a USB LED light stick based on the presence of students, as well as to program the DC motor fan to regulate the room's temperature according to the number of occupants.

> Libraries <

-> Libraries: board, digitalio, busio, APDS9960, pwmio, adafruit_motor, adafruit_ssd1306.

-> DC Motor Configuration: PWM_M1A to GP10, PWM_M1B to GP11.

-> USB Relay Configuration: GP22.

-> OLED and APDS9960 I2C Configuration: SCL = GP5, SDA = GP4.

-> Input:

< CircuitPython Code >

Click here to download code

< Expected Output >

Upon completion of the activity, you should be able to:

-> Adjusts the fan speed based on the class capacity. The fan speed will increase by 20% for every one person entering the room.

-> If there is one or more people in the room, the relay will activate (ON), lighting up the LED light stick. If the room is empty, the relay will remain deactivated (OFF).

Bonus: AP Relay

By the end of this guide, you'll be able to build your own WiFi AP network and enable EDU PICO to communicate wirelessly with other devices. Let's start with the basics - an access point, or "AP" serves as a central hub for wireless communication. It acts as a bridge between the EDU PICO and other WiFi-enabled devices, like smartphones and laptops, to enable data sharing.

This setup is incredibly helpful for various applications, including IoT (Internet of Things) projects and remote-control systems. This bonus section will guide you through the configuration for your EDU PICO to work as an access point. This means that you can connect to it, share data, and control it remotely, all over WiFi.

> Libraries <

-> Libraries: board, digitalio, wifi, socketpool, adafruit_httpserver.

-> USB Relay Configuration:

< CircuitPython Code >

Click here to download code

< Expected Output >

Upon completion of the activity, you should be able to:

-> Program starts the server and display "Starting server..." followed by "Listening on http://[IP_ADDRESS]" where [IP_ADDRESS] is the IP address of the WiFi access point.

-> You can access the control interface by connecting to the WiFi access point (AP)

(SSID: "EDUPICO_AP", Password: "12345678") using a device like a smartphone or a computer.

-> Open a web browser with server's IP address to change the relay state by clicking a button and it will send a signal to the server.

-> Messages like "Light ON" and "Light OFF" will be printed on the shell console when the buttons are clicked.

Great Work Completing Chapter 7! Let's Explore the Next Chapter