2x3A DC Motor Driver Carrier for UNIHIKER - DFRobot

Introduction

This product is a carrier specifically developed for the UNIHIKER. It uses a tilted edge connector slot to provide the screen with the best viewing angle. It integrates dual DC motor drive, which can be powered separately. At the same time, the board carries RGB lights, infrared transmission, infrared reception functions, and extends 10* 3Pin ports and 4* I2C ports. In combination with DFRobot's powerful Gravity product system, the UNIHIKER can create unlimited possibilities.

Features

Specification

Functional Diagram

Tutorial

Example 1: Using the On-board RGB LED

Note: The 'UNIHIKER Pin (P13)' block can be found under the 'Pin Operation' category in the 'UNIHIKER' extension.

#  -*- coding: UTF-8 -*-

# MindPlus
# Python

import time

from pinpong.board import Board,Pin,NeoPixel
from pinpong.extension.unihiker import *


Board().begin()

np1 = NeoPixel(Pin((Pin.P13)),3)
np1.brightness(128)

while True:
    np1.range_color(0,2,0xFF0000)
    time.sleep(1)
    np1.range_color(0,2,0x00FF00)
    time.sleep(1)
    np1.range_color(0,2,0x0000FF)
    time.sleep(1)

Example 2: Using the On-board IR TX/RX

#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board,Pin,IRRecv,NeoPixel
from pinpong.extension.unihiker import *

def event(data):
    my_variable = hex(data)
    print(my_variable)
    if (my_variable == (str("0xfd00ff"))):
        print("open")
        np1.range_color(0,2,0x0000FF)
    if (my_variable == (str("0xfd807f"))):
        print("close")
        np1.range_color(0,2,0x000000)

Board().begin()

ir1 = IRRecv(Pin((Pin.P14)),event)
np1 = NeoPixel(Pin((Pin.P13)),3)
np1.brightness(128)

while True:
    time.sleep(1)
#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board,Pin,IRRemote
from pinpong.extension.unihiker import *

Board().begin()

p_p15_irSend=IRRemote(Pin(Pin.P15))

while True:
    print("TX:0xfd00ff")
    p_p15_irSend.send(0xfd00ff)
    time.sleep(2)
    print("TX:0xfd807f")
    p_p15_irSend.send(0xfd807f)
    time.sleep(2)

Example 3: Using the On-board Motor Driver

Note: When driving the motor, you need to connect 6-12V power from the DC port, the VM light is on, otherwise the motor will not rotate.

#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board,Pin
from pinpong.extension.unihiker import *

Board().begin()

p_p5_out=Pin(Pin.P5, Pin.OUT)
p_p8_pwm=Pin(Pin.P8, Pin.PWM)
p_p6_out=Pin(Pin.P6, Pin.OUT)
p_p16_pwm=Pin(Pin.P16, Pin.PWM)

while True:
    print("Simultaneously forward at 50% speed")
    # P5 controls the direction of M1
    # P8 controls the speed of M1
    # P6 controls the direction of M2
    # P16 controls the speed of M2
    p_p5_out.write_digital(1)
    p_p8_pwm.write_analog(512)
    p_p6_out.write_digital(1)
    p_p16_pwm.write_analog(512)
    time.sleep(3)
    print("Simultaneously stop")
    # Speed is 0, the motor stops rotating
    p_p8_pwm.write_analog(0)
    p_p16_pwm.write_analog(0)
    time.sleep(3)
    print("Simultaneously reverse at 100% speed")
    # Low level means the motor reverses
    p_p5_out.write_digital(0)
    p_p8_pwm.write_analog(1023)
    p_p6_out.write_digital(0)
    p_p16_pwm.write_analog(1023)
    time.sleep(3)


Example 4: Use of External 3Pin Sensor-DHT11

#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board,Pin,DHT11
from pinpong.extension.unihiker import *

Board().begin()
dht1 = DHT11(Pin((Pin.P2)))

while True:
    print((str("temperature:") + str(dht1.temp_c())))
    print((str("humidity:") + str(dht1.humidity())))
    time.sleep(1)

Example 5: Use of External 3Pin Actuator - Servo

#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board,Pin,Servo
from pinpong.extension.unihiker import *

Board().begin()

servo1 = Servo(Pin((Pin.P3)))

while True:
    print("90")
    servo1.write_angle(90)
    time.sleep(1)
    print("10")
    servo1.write_angle(10)
    time.sleep(1)
    print("170")
    servo1.write_angle(170)
    time.sleep(1)

Example 6: Use of External I2C Sensor - Ultrasonic Sensor

#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board
from pinpong.libs.dfrobot_urm09 import URM09

Board().begin()

ult1 = URM09(0x11)
ult1.set_mode_range(ult1._MEASURE_MODE_AUTOMATIC, ult1._MEASURE_RANG_500)

while True:
    print((str("Distance:") + str(ult1.distance_cm())))
    time.sleep(1)

FAQ

Q Can the functions on the expansion board be used normally when the UNIHIKER is directly plugged in with a USB cable and the expansion board is not powered?
A Except for the motor drive and the 5V I2C port, other functions can be used normally
Q Why doesn't the motor rotate?
A 1, First check the power supply, VIN power supply is required, the VM indicator on the expansion board lights up.
2, Then check if there is a problem with the program, you can remove other programs and only test motor control.

More questions and cool idea, please visit DFRobot Forum

More Documents

DFshopping_car1.png Get 2x3A DC Motor Driver Carrier for UNIHIKER from DFRobot Store or DFRobot Distributor.

Turn to the Top