加速度传感器
MPU6050
References
Libraries
接线
- VCC:2.0 ~ 5.0V
- I2C通信:SCL/SDA接Arduino对应接口
人体感应
AM312
接线
红外传感器
树莓派安装(系统为Raspbian Stretch)
sudo apt update
sudo apt install lirc
编辑/boot/config.txt
dtoverlay=gpio-ir,gpio_out_pin=17,gpio_in_pin=18,gpio_in_pull=up
编辑 /etc/lirc/lirc_options.conf
driver = default
device = /dev/lirc0
重启sudo reboot
后,查看是否有lirc0
ls -l /dev/lirc0
lsmod | grep lirc
systemctl status lircd.service
systemctl status lircd.socket
References
- https://raspberrypi.stackexchange.com/questions/81876/raspberry-pi-3-not-lirc-not-running-working
- Remotes Database
音频
DFPlayer Mini
References
Libraries
- DFRobotDFPlayerMini
接线
- VCC:3.2 ~ 5.0V
- 通过UART接口与Arduino通信,注意Rx接口需要接1kΩ的电阻
- 似乎只能识别FAT16格式的SD卡,无法识别FAT32格式的
Usage
myDFPlayer.play(1)
表示播放SD卡中第一首歌曲(按照存入顺序?)myDFPlayer.playMp3Folder(4)
表示播放SD:/MP3/0004.mp3
myDFPlayer.playFolder(15, 4)
表示播放SD:/15/004.mp3
omxplayer
Install: pip3 install omxplayer-wrapper
from omxplayer.player import OMXPlayer
from time import sleep
VIDEO_PATH = "../tests/media/test_media_1.mp4"
player = OMXPlayer(VIDEO_PATH)
sleep(5)
player.quit()
伺服电机
云台
接线
一个电机三条线,褐色为地线,红色为接电源,橙色为控制线、接GPIO口。
通过GPIO控制角度
#!/usr/bin/python3
from time import sleep
import RPi.GPIO as GPIO
PIN_S1 = 4
PIN_S2 = 17
def clean(servers):
for s in servers:
s.stop()
GPIO.cleanup()
def rotate(servo, angle):
servo.ChangeDutyCycle(2 + 10 * (angle / 180))
if __name__ == "__main__":
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN_S1, GPIO.OUT)
GPIO.setup(PIN_S2, GPIO.OUT)
s1 = GPIO.PWM(PIN_S1, 50)
s2 = GPIO.PWM(PIN_S2, 50)
s1.start(0)
s2.start(0)
while True:
command = input('Please input servo:angle')
if command == 'q':
break
if len(command.split(':')) != 2:
print('wrong inputs')
else:
s, angle = command.split(':')
if s not in ('1', '2'):
print('wrong server number')
continue
try:
angle = int(angle)
except ValueError:
print('wrong angle')
continue
if angle < 0 or angle > 180:
print('wrong angle')
continue
if s == '1':
rotate(s1, angle)
elif s == '2':
rotate(s2, angle)
else:
continue
clean([s1, s2])
通过servoblaster
控制
安装
git clone https://github.com/richardghirst/PiBits.git
cd PiBits/ServoBlaster/user
make
sudo make install
如果安装失败报某函数没找到,可以下载旧版替换servod.c
使用
sudo ./servod
echo 0=90 > /dev/servoblaster # 舵机1转向90度
echo 0=180 > /dev/servoblaster # 舵机2转向180度
用键盘控制
#!/usr/bin/python3
import curses
import os
import time
SERVODBLASTER_PATH = '/home/pi/Projects/PiBits/ServoBlaster/user/servod'
INIT_PAN = 132
INIT_TILT = 142
if __name__ == '__main__':
#activating servo blaster
os.system('sudo ' + SERVODBLASTER_PATH)
# get the curses screen window
screen = curses.initscr()
# turn off input echoing
curses.noecho()
# respond to keys immediately (don't wait for enter)
curses.cbreak()
# map arrow keys to special values
screen.keypad(True)
#setting start up serrvo positions
#positions range from (50-250)
servo1 = INIT_PAN
servo2 = INIT_TILT
try:
while True:
char = screen.getch()
if char == ord('q'):
#if q is pressed quit
break
elif char == curses.KEY_RIGHT:
if servo1 < 150:
servo1 = servo1 +2
screen.addstr(0, 0, 'right %03d' % servo1)
os.system("echo 0=%s > /dev/servoblaster" % servo1)
time.sleep(0.005)
elif char == curses.KEY_LEFT:
if servo1 > 50:
servo1 = servo1 -2
screen.addstr(0, 0, 'left %03d' % servo1)
os.system("echo 0=%s > /dev/servoblaster" % servo1)
time.sleep(0.005)
elif char == curses.KEY_UP:
if servo2 < 150:
servo2 = servo2 +2
screen.addstr(0, 0, 'up %03d' % servo2)
os.system("echo 1=%s > /dev/servoblaster" % servo2)
time.sleep(0.005)
elif char == curses.KEY_DOWN:
if servo2 > 50:
servo2 = servo2 -2
screen.addstr(0, 0, 'down %03d' % servo2)
os.system("echo 1=%s > /dev/servoblaster" % servo2)
time.sleep(0.005)
finally:
# shut down cleanly
curses.nocbreak()
screen.keypad(0)
curses.echo()
curses.endwin()
Reference
小车资料
智能小龟套件2012:链接:https://pan.baidu.com/s/1VFBqpa4kL3EZdx1Y8bNWWQ?pwd=1ml0
提取码:1ml0
遥控超声波测距车 智能小车套件 基于Arduino:https://pan.baidu.com/s/1RyPVjO5zO8hsmlzWx4nfew?pwd=te9n
提取码:te9n
遥控超声波测距智能车:https://pan.baidu.com/s/1uJwGhn8p331YS-7yqQBaug?pwd=1ra5
提取码:1ra5
蓝牙A款多功能车资料:https://pan.baidu.com/s/1X96VITuFTNiBwWFN0HI4AA?pwd=ms6t
提取码:ms6t
高级自走车完整资料4 IN 1:https://pan.baidu.com/s/1zHOUAJfD1A9p3umxgMiElQ?pwd=oif1
提取码:oif1
智能小车大赛资料:https://pan.baidu.com/s/1QlweXLMhugyjr-43_RBAIQ?pwd=zgwq
提取码:zgwq
资料网盘下载
关于2WD小车:http://pan.baidu.com/s/1sjw16FF
L298N资料与例程: http://pan.baidu.com/s/1qW3VglQ
小车资料与论文:http://pan.baidu.com/s/1jGtRXsy
小车资料:http://pan.baidu.com/s/1i3pqq6x
小车资料:http://pan.baidu.com/s/1i3k660l
ZK-4WD小车作为模型在CCTV10 科教频道我爱发明栏目作演示,清华大学教授为其讲解原理请看视频:
//复制到IE观看
ZK-4WD小车演示:
ZK-4WD用Android手机控制演示
ZK-4WD搭载舵机与超声波避障演示
ZK-4WD寻迹
ZK-4WD弯道寻迹
遥控演示
走迷宫演示
相关资料链接:
http://pan.baidu.com/share/link?shareid=3926830886&uk=2302102993
https://www.arduino.cc/reference/tr/language/structure/further-syntax/include/
https://www.didel.com/IncludeFiles.pdf
https://forum.arduino.cc/t/how-to-use-additional-c-files-in-a-sketch/41402/2