Cov txheej txheem:

Raspberry Pi + Xbee RC Transmitter: 5 Kauj Ruam
Raspberry Pi + Xbee RC Transmitter: 5 Kauj Ruam

Video: Raspberry Pi + Xbee RC Transmitter: 5 Kauj Ruam

Video: Raspberry Pi + Xbee RC Transmitter: 5 Kauj Ruam
Video: Remote communication using XBEE modules in AT mode: Local chat service 2024, Kaum ib hlis
Anonim
Raspberry Pi + Xbee RC Transmitter
Raspberry Pi + Xbee RC Transmitter

Cov lus qhia no yuav qhia koj tias kuv tau ua dab tsi los tsim kuv tus kheej Raspberry Pi Zero + Xbee RC transmitter

Kauj Ruam 1: Raspberry PI thiab Xbee RC Transmitter

Kauj Ruam 2: Kho lub Raspberry Pi UART

Nyob zoo!

Raspberry Pi (txhua qhov kev hloov pauv) muaj ntau yam tsis txaus ntseeg thiab tam sim no yog lub hauv paus ntawm ib puag ncig ntawm ntau yam yooj yim rau cov khoom sib txuas ntxiv uas ua rau cov cuab yeej no tiag tiag. Hmoov tsis zoo ib yam uas Raspberry Pi ploj lawm (tam sim no) yog lub rooj sib tham tawg lossis turnkey GPIO interface rau XBee (ZigBee) xov tooj cua. XBee cov cuab yeej yog txoj hauv kev zoo rau kev sib txuas lus ntawm txhua yam khoom siv yam tsis muaj dicing ntau thiab txiav cov txheej txheem lossis cov ntaub ntawv tawm tswv yim thiab ua kom yooj yim heev rau kev sib txuas USB cov cuab yeej thiab xa lawv cov ntaub ntawv mus rau lwm cov khoom siv nyob deb. Txhawm rau pib, pib nrog txhua yam ntawm Raspberry Pi. Hauv Cov Lus Qhia no Kuv tau siv Raspberry Pi xoom, thiab teeb tsa lub console txuas rau kom tso dawb UART siv cov Lus Qhia no.

Kauj Ruam 3: Sau Python Script los Nyeem Game Controller Values

Qhov me me ntawm Python code ua rau cov xwm txheej tau tsa los ntawm tus tswj kev ua si thiab xa tus nqi ntawm cov tswv yim ntawm kev tswj hwm uas tau tsa qhov xwm txheej. Txoj cai no yuav xa cov ntaub ntawv kom nrawm raws li tus nqi teev tseg ntawm XBee xov tooj cua. Hauv qhov piv txwv no lub xov tooj cua tau teeb tsa rau 57600 tab sis tuaj yeem teeb tsa rau lawv qhov siab tshaj plaws. Tus tswj hwm game yog Logitech USB game game controller. Cov cai siv yog hauv qab no:

ntshuam pygame

ntshuam ntshuam

tso = ""

cov = serial. Serial {

chaw nres nkoj = '/dev/ttyAMA0', baudrate = 57600, parity = serial. PARITY_NONE, stopbits = serial. STOPBITS_ONE, bytesize = serial. EIGHTBITS, sij hawm = 1

}

pygame.init ()

ua = False

thaum ua == tsis tseeb:

joystick = pygame.joystick.joystick (0)

joystick.init ()

#QHOV TSEEB TSHIAB

rau qhov tshwm sim hauv pygame.event.get ():

yog event.type == pygame. JOYAXISMOTION:

sOut = "Axis:" + str (event.axis) + "; Tus nqi:" + str (event.value)

print (tawm)

ser.write (tawm)

ser.flush ()

tso = ""

yog event.type == pygame. JOYHATMOTION:

sOut = "Lub kaus mom: + str (event.hat) +"; Tus nqi: " + str (event.value)

print (tawm)

ser.write (tawm)

ser.flush ()

tso = ""

yog event.type == pygame. JOYBUTTONDOWN:

sOut = "Button Down:" + str (event.button)

print (tawm)

ser.write (tawm)

ser.flush ()

tso = ""

yog event.button == 8:

print ("Txiav")

ua tiav = Muaj tseeb

yog event.type == pygame. JOYBUTTONUP:

sOut = "Button Up:" + str (event.button)

print (tawm)

ser.write (tawm)

ser.flush ()

tso = ""

ser.close ()

pygame.quit ()

Kauj ruam 4: Xaus

Qhov kev tsim kawg ntawm qhov no siv lub roj teeb xov tooj pabcuam los txhawb lub Raspberry Pi, uas ua rau XBee thiab Logitech game game tswj. Hauv txoj haujlwm yav tom ntej kuv yuav ntxiv lub tshuab nqus tsev tsim yas npog uas yuav ntim nrog Raspberry PI Zero, XBee Xov Tooj Cua, thiab lub zog siv hluav taws xob, txhua qhov txuas rau tus tswj kev ua si hauv ib qho zoo, zoo nkauj. Qhov RC transmitter tsim no ua rau nws yooj yim heev xa cov ntaub ntawv tswj mus rau txhua yam. Hauv kuv qhov kev tsim tom ntej kuv yuav xa cov ntaub ntawv mus rau tus neeg hlau hexapod uas kuv tau cawm los ntawm Goodwill. Vam tias koj pom cov lus qhia no muaj txiaj ntsig. Zoo Siab Tsev!

Kauj Ruam 5: Hlau Raspberry Pi Xoom rau XBee Xov Tooj Cua

Hlau Raspberry Pi Xoom rau XBee Xov Tooj Cua
Hlau Raspberry Pi Xoom rau XBee Xov Tooj Cua

Raws li qhia hauv daim duab, txuas tus Pi GPIO tus pin 1 (3.3v) rau XBee tus pin 1. Txuas tus Pi GPIO tus pin 6 (Gnd) rau XBee tus pin 10, thiab Pi GPIO Pin 8 (TX) rau XBee tus pin 3 (Din). Koj kuj tseem tuaj yeem siv XBee pawg thawj coj tawm uas yuav xav kom koj txuas tus Pi GPIO tus pin 2 (5v) mus rau tus pin 5v ntawm pawg thawj coj tawm

Pom zoo: