最近開發的MotoPiduino持續改良修正問題,目前MotoPiduino搭配Raspberry Pi測試已告一段落,預計下個月應該可以上市! MotoPiduino主要是搭起Raspberry Pi跟Arduino之間的橋樑,可以把Arduino的擴充板直接插在MotoPiduino上作運用,除此,MotoPiduino還有內建馬達驅動IC,可以直接驅動兩顆DC直流馬達. 此影片範例即是利用Android手機遙控Raspberry Pi來控制馬達運轉! 在Part 2中將接上Raspberry Pi專用的攝影模組,可以即時傳輸影像(這是Arduino所辦不到), 敬請期待!!
使用材料:
1. Raspberry Pi
2. MotoPiduino
3. 5V 行動電源
4. 9V 電池 (驅動馬達)
5. USB WiFi Dongle
6. 圓形車體
遙控車程式(Python):
----------------------------------------------------
#Get the GPIO module
import RPi.GPIO as GPIO
#Get the time module
import time
#Get the socket module
import socket
#Some IP constants for this, the server
UDP_IP = "192.168.0.113" // 請修改成自己的 IP Address
UDP_PORT= 8888 // default port : 8888
#A routine to control a pair of pins
def ControlAPairOfPins(FirstPin,FirstState,SecondPin,SecondState):
print("Controlling pins")
if FirstState == "1":
GPIO.output(int(FirstPin),True)
else:
GPIO.output(int(FirstPin),False)
if SecondState == "1":
GPIO.output(int(SecondPin),True)
else:
GPIO.output(int(SecondPin),False)
#Just retur
return
####Main body of code
#Get rid of warnings
GPIO.setwarnings(False)
#Set the GPIO mode
GPIO.setmode(GPIO.BOARD)
#Set the pins to be outputs
GPIO.setup(11,GPIO.OUT)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
#Set up the IP related details
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
print "Pi_Robot server started ...."
while True:
#Wait for a UDP command to be received
print("Waiting for UDP command")
MyChar, addr = sock.recvfrom(1024) #buffer size is 1024
print "I received: " + MyChar
if MyChar == "forward":
ControlAPairOfPins("12","1","13","1")
ControlAPairOfPins("11","1","15","1")
print "Forward"
elif MyChar == "stop":
ControlAPairOfPins("12","0","13","0")
ControlAPairOfPins("11","0","15","0")
print "Stop"
elif MyChar == "back":
ControlAPairOfPins("12","1","13","0")
ControlAPairOfPins("11","1","15","0")
print "Back"
elif MyChar == "left":
ControlAPairOfPins("12","1","13","1")
print "Left"
elif MyChar == "right":
ControlAPairOfPins("11","1","15","1")
print "Right"
else:
print "Not a command"
相關資訊:
http://www.motoduino.com (motopiduino user guide and android app download)
http://sinocgtchen.blogspot.tw/
使用材料:
1. Raspberry Pi
2. MotoPiduino
3. 5V 行動電源
4. 9V 電池 (驅動馬達)
5. USB WiFi Dongle
6. 圓形車體
遙控車程式(Python):
----------------------------------------------------
#Get the GPIO module
import RPi.GPIO as GPIO
#Get the time module
import time
#Get the socket module
import socket
#Some IP constants for this, the server
UDP_IP = "192.168.0.113" // 請修改成自己的 IP Address
UDP_PORT= 8888 // default port : 8888
#A routine to control a pair of pins
def ControlAPairOfPins(FirstPin,FirstState,SecondPin,SecondState):
print("Controlling pins")
if FirstState == "1":
GPIO.output(int(FirstPin),True)
else:
GPIO.output(int(FirstPin),False)
if SecondState == "1":
GPIO.output(int(SecondPin),True)
else:
GPIO.output(int(SecondPin),False)
#Just retur
return
####Main body of code
#Get rid of warnings
GPIO.setwarnings(False)
#Set the GPIO mode
GPIO.setmode(GPIO.BOARD)
#Set the pins to be outputs
GPIO.setup(11,GPIO.OUT)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
#Set up the IP related details
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
print "Pi_Robot server started ...."
while True:
#Wait for a UDP command to be received
print("Waiting for UDP command")
MyChar, addr = sock.recvfrom(1024) #buffer size is 1024
print "I received: " + MyChar
if MyChar == "forward":
ControlAPairOfPins("12","1","13","1")
ControlAPairOfPins("11","1","15","1")
print "Forward"
elif MyChar == "stop":
ControlAPairOfPins("12","0","13","0")
ControlAPairOfPins("11","0","15","0")
print "Stop"
elif MyChar == "back":
ControlAPairOfPins("12","1","13","0")
ControlAPairOfPins("11","1","15","0")
print "Back"
elif MyChar == "left":
ControlAPairOfPins("12","1","13","1")
print "Left"
elif MyChar == "right":
ControlAPairOfPins("11","1","15","1")
print "Right"
else:
print "Not a command"
----------------------------------------------------------------
http://www.motoduino.com (motopiduino user guide and android app download)
http://sinocgtchen.blogspot.tw/
請問這塊板子有在賣了嗎
回覆刪除不好意思! 十一月份才會上市開賣!!
刪除請問可以給紅外線接收器的電路圖嗎??
回覆刪除您是指那個 紅外線接收器的電路圖?
刪除請問一下,現在 MotoPiduino 可以在那裡買到呢?
回覆刪除目前正準備量產,預計二月會上市.
刪除請問UDP傳輸的控制app有提供嗎?
回覆刪除或是有相關教學,今天買了MotoPiduino想來實作視訊遙控車
利用email寫信給我, 我寄給你app code!
刪除您好,請問我在圖上看到您有裝設鏡頭,您所拍攝的連續影像,目前可以即時傳回接收端嗎?謝謝
回覆刪除請問這個camera的架子 有再販售嗎?
回覆刪除