In this chapter, we learn to
program EDU PICO V2 to control a DC motor - spinning direction and speed control.
turn ON and OFF a USB switch relay.
Introduction: DC Motor and USB Relay.
AI Task #1: Use the potentiometer to control the speed and direction of the DC motor.
AI Task #2: Use Button A to toggle the relay ON and OFF (like a light switch).
Activities: Build a smart classroom with a gesture sensor, USB relay, DC motor, and OLED.
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 robotic arms. Consider it as a tool that can transform your ideas into reality. Let’ s get this thing moving!
-> Libraries: board, time, busio, pwmio, adafruit_motor.
-> DC Motor Configuration:
PWM_M1A to GP10, PWM_M1B to GP11.
Connect DC Motor to M1A & M1B terminals as shown below:
Upon completion of the activity, you should be able to:
-> 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.
Task:
-> Use the potentiometer to control the speed and direction of the DC motor.
Upon completion of the activity, you should be able to:
-> See turning the potentiometer knob to the left spins the motor backward, turning it to the center stops the motor and turning it to the right spins the motor forward.
From the previous chapter, we have learned how to operate the potentiometer module oon the EDU PICO V2, now, it is time we make use of that knowledge in this mini-activity. Let's program our EDU PICO V2 to control the DC motor speed using the potentiometer. Sounds simple right? Let's give a try!
-> Libraries: board, time, AnalogIn, pwmio, adafruit_motor.
-> DC Motor Configuration:
PWM_M1A to GP10, PWM_M1B to GP11.
Connect DC Motor to M1A & M1B terminals as shown below:
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.
In this lesson, we will learn how to operate the USB relay on the EDU PICO V2, 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 essential component in various electrical and electronic applications. In this case, we will use the EDU PICO V2 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: board, digitalio.
-> USB Relay Configuration:
Initialize relay to pin GP22 and set the pin direction to output.
Upon completion of the activity:
-> 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.
Task:
-> Use Button A to toggle the relay ON and OFF (like a light switch).
Upon completion of the activity
-> When you press Button A, the relay turns ON and the LED stick lights up. When you press Button A again, the relay turns OFF and the LED stick turns off as well.
In this project, we will learn to integrate PAJ7620 gesture sensor to track students ’ 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: board, digitalio, busio, edupico2_paj7620, pwmio, adafruit_motor, adafruit_ssd1306.
-> DC Motor Configuration: PWM_M1A to GP10, PWM_M1B to GP11.
-> USB Relay Configuration: GP22.
-> OLED and PAJ7620 I2C Configuration: SCL = GP5, SDA = GP4.
-> Input:
Swipe your hand from left to right above the gesture sensor to increase the number of students by 1.
Swipe your hand from right to left above the gesture sensor to subtract the number of students by 1.
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).