Cov txheej txheem:

Arduino Shooting Game V3: 4 Cov Kauj Ruam
Arduino Shooting Game V3: 4 Cov Kauj Ruam

Video: Arduino Shooting Game V3: 4 Cov Kauj Ruam

Video: Arduino Shooting Game V3: 4 Cov Kauj Ruam
Video: I made a CSGO C4 prop IRL 2024, Kaum ib hlis
Anonim
Image
Image
Arduino Shooting Game V3
Arduino Shooting Game V3
Arduino Shooting Game V3
Arduino Shooting Game V3
Arduino Shooting Game V3
Arduino Shooting Game V3

Qhov kev ua si no yog rau koj uas siv airsoft lossis co2 tua ntawm lub hom phiaj. Nws yog kev ua si.

Txog rau hnub tim cov ntaub ntawv hais txog qhov kev ua si thiab kev txhawb nqa:

www.facebook.com/arduinoshooting/

Rau kuv blog nplooj ntawv hais txog qhov kev ua si:

shootinggameblog.wordpress.com

Rau cov lej hais txog kev ua si:

github.com/shootinggame82/Shooting-game-v3

Kev ua si tua phom yog x lub hom phiaj uas tsis muaj wireless, txhua lub hom phiaj muaj lub ntsej muag lub ntsej muag uas hnov qhov kev co uas tau txais thaum raug ntaus. Cov ntsuas hluav taws xob tsis siv hluav taws xob yog Atmega328 nti (Arduino Uno nti) thiab tau them roj teeb Li-Po.

Tus tswj hwm tseem ceeb rau qhov kev ua si no yog tswj los ntawm Arduino thiab yog Serial tswj los ntawm Raspberry Pi.

Yog li qhov kev ua si no ua haujlwm li cas? Zoo nws yog 3 hom game:

Sijhawm Ceev: Ua si X puag ncig thiab tua kom nrawm koj tuaj yeem ua tau ntawm txhua lub hom phiaj.

Timemode: Tua ntau lub hom phiaj koj tuaj yeem ua rau X vib nas this.

Rapidfire: Tua X txhaj rau lub sijhawm nrawm tshaj plaws.

Cov kab ke peb NRF24L01 cov xa tawm kom tau txais qhov zoo nyob deb ntawm tus tswj hwm tseem ceeb. Lawv ua haujlwm ntawm 2.6 GHz (Tib yam li WiFi ua haujlwm)

Hauv kuv cov phiaj xwm yav dhau los kuv tau siv Piezo rau kev co, tab sis tam sim no Kev Ruaj Ntseg Sensor Hloov tau siv, tab sis koj tseem tuaj yeem siv Piezo yog tias koj tau ua kuv qhov qub version ntawm qhov kev ua si.

Qhov kev ua si muaj Raspberry Pi 7 kov lub vijtsam uas tuav lub vev xaib uas koj tswj hwm qhov kev ua si los ntawm lub tshuab luam ntawv dav hlau luam tawm cov txiaj ntsig.

Khoom siv

Rau transmitters:

  • X Atmega328 nrog Arduino Bootloader (Nyob ntawm seb muaj pes tsawg lub hom phiaj)
  • X Kev co Sensor Hloov
  • X Blue Coj
  • X Ntsuab Led
  • X Liab Coj
  • X 3.7v Li-Po roj teeb
  • X FC-75 Li-Po Charger module (lossis lwm tus qauv)
  • X 100 uF Capacitor
  • X Cov ntaub ntawv rau cov ntsuas
  • X LD1117V33 (Ua kom muaj kev nyab xeeb 3.3 V rau cov xa tawm)
  • X NRF24L01 Modules
  • X x 3 220 Ohm Resistors (3 xav tau rau ib lub hom phiaj)
  • X 16 MHz Crystal
  • X x 2 Cov Capacitors Tsis Txaus Siab 22 pF (2 xav tau rau ib lub hom phiaj)

Rau lub ntsiab Arduino:

  • 1 Arduino (Nano lossis Uno tau pom zoo, yuav tsum muaj USB)
  • 1 NRF24L01 Module
  • 1 10 uF capacitor

Rau raspberry Pi:

  • Raspberry Pi (Kuv siv 3B)
  • 7 "Kov Screen
  • ATXRaspi (Yeem tab sis lub zog khawm zoo)
  • RTCRaspi (Yeem tab sis zoo RTC module khaws lub sijhawm thiab hnub tim)
  • Lub tshuab luam ntawv ib ntus (Yeem tab sis xav tau kom tuaj yeem luam tau)
  • Barcode scanner (USB version uas ua haujlwm zoo li keyboard, Yeem tau)
  • Lub zog zoo 5V (Kuv siv lub qub 12v USB nrog 2.5 A lub zog)

Lwm cov khoom:

  • Lub zog 12v (Kuv muaj ib qho ntawm 12 Ah)
  • Network socket (Ua kom yooj yim txuas rau Network)
  • Cov kab

Kauj ruam 1: Wireless Sensors

Cov Wireless Sensors
Cov Wireless Sensors
Cov Wireless Sensors
Cov Wireless Sensors
Cov Wireless Sensors
Cov Wireless Sensors

Wb pib ua cov sensors. I siv 4 sensors rau qhov kev ua si. Tab sis koj tuaj yeem yooj yim ntxiv cov sensors. Qhov sensors tau sib tham nrog 4 tus lej lej thaum lub hauv paus tseem ceeb xa tawm cov cai nrog ua haujlwm li cas lub sensor nrog txoj cai raug yuav teeb thiab npaj rau lub hom phiaj. Lub teeb xiav yog qhia tias nws yog lub hom phiaj uas koj yuav mus.

Peb kuj muaj ntsuab thiab liab coj. Cov ntsuab ib txwm teeb tsa los qhia tias lub ntsuas cua nyob. Liab yuav tsuas yog lub teeb thaum lub roj teeb tsawg dua 3.1V (nws siv lub hauv paus ua haujlwm hauv nti los xam seb muaj pes tsawg hauv lub roj teeb.

Lub ntsuas kev co tau txuas nrog tus pin analog thiab nyeem nws tus nqi. Thaum tus nqi poob qis, lub ntsuas cua tau teeb tsa qhov kev co thiab qhov ntawd yog qhov uas peb sau npe ntaus.

Lub hom phiaj muaj qhov ua tsis tau zoo, qhov xwm txheej koj tsis tsoo hauv X vib nas this (lub neej ntawd yog 15 vib nas this) lossis yog tias kev xa xov tsis tuaj yeem ua tiav hauv lawv yuav rov qab mus pib txoj haujlwm.

Kuv yuav tsis piav qhia tias koj yuav xaim li cas, txheeb xyuas daim ntawv hluav taws xob seb koj yuav ua li cas. Qhov ntawd yog ntawm koj los txiav txim siab seb koj xav li cas.

TSEEM CEEB NTAWM NRF24L+ Module:

Nws tuaj yeem ua rau mob … kom ua rau lawv ruaj khov, ua ke nrog lub zog zoo thiab cais ib puag ncig nws, thiab cov cai koj yuav ua rau lawv ua haujlwm. Rau kuv 10 uF capacitor yuav muab rau kuv ruaj khov thiab muaj kev sib txuas zoo, tab sis thov sim ua ntej qhov koj xav tau piv txwv 100 uF capacitor. Kuj qhwv lawv nrog thawj cov ntawv yas thiab tom qab ntawv Aluminium ntawv ci los tiv thaiv lawv los ntawm kev cuam tshuam

Tsis tas li hauv cov cai, cov ntaub ntawv tus nqi koj tsis xav tau ntau dua 250 Kb yog li ntawd yuav tsis muaj teeb meem. Tab sis PA: myRadio.setPALevel (RF24_PA_MIN);

Hauv cov cai kuv tau teev rau MIN (Qhov no yog thaum sim), nws qis tshaj thiab yuav tsis siv lub zog ntau, tab sis qhov ntau yuav tsis ntev li ntawd. Yog tias koj tau txais kev ruaj khov thiab lub zog zoo rau lawv, koj tuaj yeem nce mus rau RF24_PA_MAX kom tau txais qhov ntev tshaj plaws, Tab sis lawv xav tau GOOOOOD lub zog ruaj khov rau qhov ntawd. Sim kuj LOW THIAB HIGH (Hloov MAX cov ntawv nkaus xwb) los saib seb koj puas tau txais kev sib txuas lus zoo. Tsis tas li koj yuav tau txais txiaj ntsig zoo ntawm LOW thiab HIGH tshwj tsis yog tias koj yuav yog tus neeg tua phom

Tsis tas li khaws cov xa xov sib nrug tsawg kawg ib 'meter' nrug, kom kaw tuaj yeem ua rau lub teeb liab tsis zoo

Ntsuas kev sib txuas lus nrog qee qhov piv txwv ping hauv NRF24 Lub Tsev Qiv Ntawv (Txuas ntawm GitHub)

Hauv txoj cai koj yuav tsum teeb tus lej cim tus cim rau lub hom phiaj ntawd:

pem targID = 3401; // Qhov no yog lub hom phiaj ID

int xaID = 2401; // Nov yog tus ID teb

Kuj tseem muaj 3 DEFINE lub luag haujlwm:

#define DEBUG

#define roj teeb

#define SHAKE // YOG SHAKE SWITCH raug siv los ntawm PIEZO qub

DEBUG:

Thaum lub sijhawm xeem qhov no yog qhov zoo uas tau piav qhia. Tab sis thaum koj ua kom lawv muaj, tsis txhob qhib nws.

Roj teeb:

Yog tias koj tsis xav kom muaj lub ntsuas roj teeb rau lub hom phiaj, koj yuav tsum tshem qhov kev txhais no.

HLOOV:

Yog tias koj tau tsim kuv cov ntawv qub, koj muaj piezo sensors, tom qab ntawd tshem qhov no kom tau txais cov cai raug rau lawv.

ATMEGA328 Chip

Hloov chaw ntawm Arduino nano Kuv txiav txim siab siv ATMEGA328 nti (nrog Uno boot loader), lawv yooj yim rau kev ua haujlwm tsuas yog tshem tawm cov nti los ntawm Arduino Uno thiab ntxiv cov nti no thiab xa cov lej. Txheeb xyuas cov phiaj xwm hluav taws xob yuav tsim lub hom phiaj li cas.

Txoj Cai

Kuv tau sau cov cai nrog PlatformIO hloov chaw ntawm Arduino IDE. Nws yog software zoo dua rau program hauv. Yog li cov cai sib txawv me ntsis. Kuv pom zoo kom siv cov software no hloov.

Lub Hom Phiaj & Lub Thawv Xa Ntawv

Kuv tau txuas lub sensor thiab xiav coj ntawm lub hom phiaj, thiab nrog 3, 5 mm phono cable ntawm 2 m kuv txuas nws ua ke hauv lub thawv xa khoom uas tuav lub atmega nti, roj teeb them nyiaj thiab ntsuab & liab coj. Qhov no yog los tiv thaiv nws los ntawm kev raug ntaus nrog cov mos txwv hlau.

Kauj ruam 2: Game Controller

Game Controller
Game Controller
Game Controller
Game Controller
Game Controller
Game Controller
Game Controller
Game Controller

Qhov tom ntej no peb yuav tsum tau ua yog ua tus tswj rau cov ntsuas. Nws yog Arduino uas siv NRF24L01 tus qauv los sib txuas lus nrog cov ntsuas. Tsis muaj dab tsi ntxiv. Tom qab ntawd Arduino txuas nrog USB hauv raspberry pi kom ua haujlwm.

Nov yog yuav ua li cas. Nws siv cov lej kom paub ua dab tsi. Pi yuav xa tawm cov lus txib. Ua ntej thaum teeb tsa nws xa tawm pes tsawg lub hom phiaj uas koj tau ntxiv, thiab cov hom phiaj cim tus lej. Tom qab ntawd nws yuav ua qhov kev ntsuas ua haujlwm thiab qhia rau raspberry pi yog tias lawv sib tham nrog lwm tus.

Thaum koj ua si qhov kev ua si nws yuav xa los ntawm pi yam kev ua si twg thiab muaj pes tsawg qhov sib tw/ntaus kom siv. Tias nws.

Nws muaj peev xwm siv NRF24L01 cov qauv hauv raspberry pi, tab sis rau kuv Arduino yog qhov kev xaiv zoo dua kev txhaum kuv yeej tsis siv lawv hauv raspberry yog li kuv tsis paub tias lawv ua haujlwm tau zoo nyob rau lub sijhawm ntev

Muaj lub zog siv hluav taws xob uas siv 5 v txhawm rau txhim kho lub zog ruaj khov rau cov hloov pauv. Koj tuaj yeem siv lawv nrog koj Arduino (Saib daim duab) lub npe yog Socket Adapter Module Board

Thaum koj ua si lub hom phiaj yuav raug qhib ua haujlwm ib tus zuj zus. Thaum ib tus raug ntaus, lwm tus yuav raug qhib.

Thaum ntsuas koj tuaj yeem muaj #DEFINE DEBUG qhib kom pom nws ua haujlwm li cas, tab sis tsis yog thaum koj siv nws hauv pi computer, nws yuav tsis ua haujlwm tom qab ntawd.

Rub tawm cov cai ntawm nplooj GitHub.

Kauj Ruam 3: Raspberry Pi

Raspberry Pi
Raspberry Pi
Raspberry Pi
Raspberry Pi
Raspberry Pi
Raspberry Pi
Raspberry Pi
Raspberry Pi

Tam sim no peb tau los rau Raspberry Pi.

Kuv tau ntxiv qee qhov haujlwm ntxiv yog li kuv tuaj yeem muaj lub hwj chim khawm. ATXRaspi 3 yog tus qauv zoo, koj tuaj yeem qhib, tua thiab rov pib dua pi nrog lub pob. Tsis tas li RTCRaspi khaws lub sijhawm thiab hnub tim ntawm pi. Kuj tseem ua rau nws tuaj yeem tsuas yog txuas lub network cable txuas kuv yuav tsum tau ua qee qhov hloov tshiab ntawm cov kab ke. Koj yuav pom lawv ntawm Lowpowerlab

Lub Tshuab Luam Ntawv Thermal koj yuav pom ntawm sparkfun thiab tus lej nyeem barcode muaj nyob ntawm amazon.

Pi lub computer khiav hauv kiosk hom yog li qhov browser yuav qhib thaum pib. Ua ntej tshaj plaws koj yuav tsum muaj lub vev xaib nrog PHP 7 thiab mysql ntawm pi computer. (Muaj ntau cov lus qhia nyob ib puag ncig lub vev xaib rau qhov no)

THOV NCO TSEG: yog tias koj yuav siv lub tshuab luam ntawv cua sov nrog raspberry pi uas tau tsim hauv bluetooth koj yuav tsum tau xiam qhov ntawd ua ntej

Python tsab ntawv xav tau pyserial thiab koj nruab nws: sudo apt-tau nruab sej-serial

Txhawm rau ua kom mysql ua haujlwm teeb tsa hauv qab no:

sudo apt-tau nruab mysql-python sudo apt-tau nruab python-mysql.connector

suso apt-tau nruab pymysql

Tam sim no koj tuaj yeem tswj hwm koj Arduino hla cov lej thiab tseem hloov kho mysql database.

Cov kauj ruam tom ntej yog ua tsab ntawv nab nab los txuas rau mysql.

Hauv tag nrho peb tsab ntawv nab hab sej hloov kev sib txuas rau koj li mysql database.

Cov kauj ruam tom ntej yog ua kom cov nab hab sej tsab ntawv khiav thaum pib.

Muaj peb tus nab npawb script.game.py yog qhov tseem ceeb tshaj plaws ntawm txhua qhov, uas ib tus tuav cov game game.print.py qhov no tsuas yog xav tau yog tias koj yuav siv lub tshuab luam ntawv ib ntus los luam tawm.ean.py tsuas yog xav tau yog tias koj yuav siv barcode scanner.

Txhawm rau kom lawv autostart kuv kho:

sudo nano /etc/rc.local

thiab ntxiv cov hauv qab no hauv qab ua ntej tawm 0:

sudo python /home/pi/Gamefiles/game.py & sudo python /home/pi/Gamefiles/print.py & sudo python /home/pi/Gamefiles/ean.py &

Thov hloov kho qhov chaw raug rau koj tsab ntawv nab nab thiab tsis txhob hnov qab & kos npe thaum kawg

Tam sim no peb yuav tsum ua hom kiosk rau webbrowser, xub tshem tus cursor:

sudo apt-tau nruab unclutter

sudo nano/etc/xdg/lxsession/LXDE-pi/autostart

tam sim no hauv cov ntawv ntawd nrhiav thiab tawm tswv yim:

@xscreensaver -no -splash # tawm tswv yim kab no tawm los xiam cov ntxaij vab tshaus

Hauv qab no ntxiv:

@xset s off @xset -dpms @xset s noblank @chromium-browser --noerrdialogs-force-device-scale-factor = 1.25 --kiosk https:// localhost

Cov kauj ruam tom ntej kom tshem tag nrho cov ntawv khau raj thiab khoom ntxiv rau koj tus kheej lub vijtsam khau raj ntawm no yog cov lus qhia nrawm:

sudo nano /boot/config.txt thiab hauv qab adddisable_splash = 1

Tshem cov ntawv xov hauv qab cov duab txaws:

sudo nano /usr/share/plymouth/themes/pix/pix.script

Nrhiav thiab tshem tawm (lossis tawm tswv yim tawm):

message_sprite = Sprite (); message_sprite. SetPosition (screen_width * 0.1, screen_height * 0.9, 10000);

thiab:

my_image = Image. Text (ntawv nyeem, 1, 1, 1); message_sprite. SetImage (my_image);

Tam sim no peb tshem cov lus khau raj:

sudo nano /boot /cmdline.txt

hloov "console = tty1" nrog "console = tty3"

thiab qhov kawg ntawm kab ntxiv:

txaws ntsiag to plymouth.ignore-serial-consoles logo.nologo vt.global_cursor_default = 0

Thiab hloov pauv pi nrog koj tus kheej:

sudo cp ~/my_splash-p.webp" />

Tam sim no koj muaj koj tus kheej kev cai khau raj rau koj cov game. Koj lub khoos phis tawj pi tam sim no tau npaj los daws qhov game. So dhau mus rau qib tom ntej!

Kauj ruam 4: Teeb Game

Txij ntawm no koj tam sim no tau tsim qhov kev ua si.

Ua ntej koj yuav tsum tau ua yog teeb tsa lub webbsystem. Rub cov ntaub ntawv khaws cia rau koj tus neeg rau zaub mov mysql. Cov ntaub ntawv nyob hauv suav nrog daim nplaub tshev thiab muaj npe database.sql

Cov kauj ruam tom ntej yog txhawm rau kho cov ntaub ntawv teeb tsa, koj pom nws hauv suav nrog lub npe nplaub tshev config.php Hloov cov ntaub ntawv nkag mus rau cov ntaub ntawv yog li ntawv yuav ua haujlwm.

Lub vev xaib yog ntau hom lus thiab tau sau ua lus Askiv. Muaj lus txhais ua lus Swedish. Txhawm rau ua ntau hom lus koj xav tau software npe hu ua Poedit.

Txhawm rau ntxiv cov lus ntxiv rau lub vev xaib system koj yuav tsum hloov kho i18n_setup.php thiab ntxiv hauv kab lus:

return in_array ($ qhov chaw, ['en_US', 'sv_SE']); (Kab 23)

Tsis tas li los hloov cov lus tsis raug koj yuav tsum hloov pauv kab 27: $ lang = 'en_US'; hloov en_US rau koj cov lus.

cov ntaub ntawv lus yuav tsum tau muab tso rau hauv ib puag ncig/LANGCODE/LC_MESSAGES/thiab muaj npe main.mo (Hloov langcode rau koj hom lus)

kom hloov cov keyboard hauv cov ntaub ntawv selectplayers.php koj hloov cov lus: "en", // en rau lus Askiv sv rau lus swedish: 'qwerty', // qwerty rau lus Askiv swedish-qwerty rau swedish

Koj pom lawv ntawm kab 218 & 219

Cov lus muaj nyob hauv daim nplaub tshev: cov cuab tam/js/keyboard/lus & txheej txheem yog nyob hauv cov cuab tam/js/keyboard/txheej thiab ntxiv cov ntaub ntawv raug rau kab 118 thiab 119 (hloov qhov koj pom tam sim no)

Ntxiv cov hom phiaj

Txhawm rau ntxiv cov hom phiaj koj mus rau localhost/ admin/ thiab nyem rau ntawm lub hom phiaj ntxiv.

Koj yuav tsum tau ntxiv lub npe rau lub hom phiaj thiab tus lej cim tshwj xeeb thiab xa ID, ntxiv ntau lub hom phiaj uas koj muaj.

Ntxiv kev ua si

Koj kuj yuav tsum tau ntxiv qee qhov kev ua si. Mus rau localhost/ admin/ thiab nyem rau ntxiv game

Koj yuav tsum tau ntxiv lub npe rau qhov kev ua si, kev piav qhia, min thiab max players yam kev ua si twg, kuj nyuaj npaum li cas qhov kev ua si yog ntawm 1 txog 5. Thiab qhov kev ua si yog li cas, yog li rau qhov kev ua si nrawm koj ntxiv ntau npaum li cas (piv txwv 30) rau kev kos sai npaum li cas puag ncig (piv txwv li 8) thiab rau lub sijhawm ntev npaum li cas lawv yuav mus ua si (piv txwv li 60 rau ib feeb)

Pib qhov kev ua si

Thaum koj txhawb nqa qhov kev ua si nws yuav ua qhov kev sim phiaj xwm. Yog li cov hom phiaj yuav tsum yog ua ntej koj pib lub hauv paus tseem ceeb. Yog tias txhua qhov dhau qhov kev sim koj tuaj yeem siv qhov system, tab sis yog lawv tsis ua koj tsis tuaj yeem siv nws. Nws yuav sim sib txuas lus kom txog thaum lawv tau txais cov lus teb.

Hmoov zoo

Zoo uas yog hais txog nws, rau kev txhawb nqa thiab cov ntaub ntawv hais txog kev hloov kho tshiab hauv cov cai thov ua raws kuv tus Facebook nplooj ntawv rau qhov kev ua si no, yog li kuv tuaj yeem teb koj sai. Koj yuav pom cov kev sib txuas saum toj no.

Pom zoo: