Mundarija:
- 1 -qadam: Uskuna talablari
- 2 -qadam: Xavfsizlik
- 3 -qadam: himoya
- 4 -qadam: O'yin -kulgi
- 5 -qadam: IOT App Watson IBM Bluemix -da [Birinchi qism]
- 6 -qadam: Qizil oqim tugunlari
Video: Umumiy nuqtai: Uydagi o'yin -kulgi va xavfsizlik tizimi: 6 qadam
2024 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2024-01-30 13:26
Ilova haqida
Bu IOT tizimi uy o'yin -kulgi va xavfsizlik tizimi.
-
Xavfsizlik
- RFID kartasini bosing va kirishlar Firebase -ga saqlanadi.
- Agar ruxsat berilgan bo'lsa, siz tinchgina kirishingiz mumkin va rasm S3 -ga yuklanadi
- Agar ruxsatsiz bo'lsa, mudofaa bo'limi keladi va LCD displey sizga ruxsat yo'qligini aytadi.
- Mudofaa
- Boshqaruv panelidagi tugmani bosing.
- Lazer minoralari tasodifiy portlash va tezlikda hujum qiladi.
-
O'yin -kulgi
- Agar harakat aniqlansa, o'yin boshlanadi.
- Foydalanuvchi o'yinni o'ynaganidan so'ng, hisob Firebase -ga saqlanadi.
- LDR qiymatlari olinadi va asboblar panelida chiqariladi.
Bu dasturni IBM Node-Red veb-serveri orqali boshqarish va ko'rish mumkin. Biz AWS va IBM Cloud Services -dan foydalanamiz va Firebase -dan ma'lumotlar bazamiz sifatida foydalanganmiz.
Ta'riflanadigan qadamlar haqida qisqacha ma'lumot
- Uskuna talablari
- Xavfsizlik - RFID kiritish va tasvirni aniqlash dasturidan foydalanadigan xavfsizlik tizimini qanday yaratish kerak
- Mudofaa - Lazerli minorani qanday yaratish kerak
- O'yin -kulgi - Simon aytadigan o'yinni qanday yaratish kerak
- IBM Bluemix -dagi IOT App Watson - Qanday qilib barcha tizimlarni bitta boshqaruv paneliga birlashtirish mumkin
Davom eting va ushbu loyihani qanday yaratish haqida batafsil tushuntirish uchun pdf faylga kiring.
1 -qadam: Uskuna talablari
Bu sizga kerak bo'ladi
-
Xavfsizlik
- 1 Raspberry Pi
- 1 LCD
- 1 RFID o'quvchi
- 1 PiCam
- 2 ta RFID karta/tugma
- X Ayol -> Erkak o'tish kabellari
- Mudofaa
- 1 Raspberry Pi
- 2 10 ㏀ rezistor (tugmalar uchun)
- 2 mikro -servo
- 1 650nm lazer uzatuvchi moduli
- 2 bosish tugmasi
- 1 Buzzer
- 3 ta kichik kauchuk bantlar/kabel bog'lamlari (mahkamlash uchun)
- X Ayol -> Erkak o'tish kabellari
- X Oddiy o'tish kabellari
- 1 tranzistor
- 1 kondansatör
-
O'yin -kulgilar
- 1 Raspberry Pi
- 3 1, qarshilik (LEDlar uchun)
- 1 10㏀ qarshilik (LDR uchun)
- 3 ta LED (turli xil ranglar)
- 3 tugma
- 1 LDR
- 1 LCD
- 1 Pir harakat sensori
- X Ayol -> Erkak o'tish kabellari
- X Oddiy o'tish kabellari
2 -qadam: Xavfsizlik
Xavfsizlik tizimi uskunalarini yaratish
Devorlarni chizish diagrammasida ko'rsatilgandek ulang
Xavfsizlik tizimi uchun dasturiy ta'minot yaratish
- Biror narsa yaratish orqali AWS -ni sozlang
- AWS Python kutubxonasini o'rnating
- LCD kutubxonasini o'rnating
- RFID kutubxonasini o'rnating
- Firebase -ni o'rnatish
- S3 saqlash joyini sozlash
- Raspberry Pi -ga Boto -ni o'rnating
- AWS ClI -ni Raspberry Pi -ga o'rnating
- AWS hisob ma'lumotlarini yarating
- AWS -ni sozlash
- Security.py faylini RPi -ga yuklang
- Imagerecognition.py faylini RPi -ga yuklang
security.py - bu rfid kirishini o'qiy oladigan va foydalanuvchi buzg'unchilik qiladimi yoki yo'qligini aniqlaydigan kod. Agar foydalanuvchi aniqlansa, rasm olinadi va s3 ga yuklanadi. Kod, shuningdek, aws MQTT -da mavzuni e'lon qiladi
3 -qadam: himoya
Lazer minorasi uskunalarini yaratish
- Biz 2 ta servo va 1 ta lazer moduli yordamida lazerli minorani yaratamiz
- Devorlarni chizish sxemasida ko'rsatilgandek ulang
Lazerli minorali dasturiy ta'minot yaratish
Quyidagi kod lazerli minorani tasodifiy yo'nalishlarda, tasodifiy portlashlar va tezlikda otishga imkon beradi
laserturret.py
gpiozero importidan LED, Buzzer, Tugma, Servoimport signalining import pauzasidan import vaqti tasodifiy
#LED = LED (12)
#pir = MotionSensor (19, sample_rate = 5, queue_len = 1) buzzer_pin = Buzzer (17) hujum = Button (5, pull_up = False) #reset = Button (6, pull_up = False) servo1 = Servo (18) servo2 = Servo (24)
def ledON ():
led.on () print ("LED yoniq") def ledOFF (): led.off () chop etish ("LED o'chirilgan")
def Fire ():
chop etish ("qurollar issiq") buzzer_pin.on () time.sleep (0.1) buzzer_pin.off ()
def laserturret ():
timeBetweenBurst = random.uniform (0.2, 1) timeBetweenShots = random.uniform (0.05, 0.2) servo1start = random.randrange (-1, 1) servo1end = random.randrange (-1, 1) servo2start = random.randrange (-1, 1) servo2end = random.randrange (-1, 1) numShots = random.randrange (5, 20) servo1change = (servo1end - servo1start)/numShots servo2change = (servo2end - servo2start)/numShots servo1.value = servo1start servo2.value = servo2start time.sleep (0.1) tortishish = 0 detal = [timeBetweenBurst, timeBetweenShots, servo1.value, servo2.value, numShots] otish paytida bosib chiqarish (tafsilot) <numshots: shot+= "1" servo1.value = "servo1start" servo2.value = "servo2start" servo1start = "servo1change" servo2start = "servo2change" fire () = "" time.sleep (timebetweenshots) = "" time.sleep (timebetweenburburst)
eslatmalar = {
'B0': 31, 'C1': 33, 'CS1': 35, 'D1': 37, 'DS1': 39, 'EB1': 39, 'E1': 41, 'F1': 44, 'FS1 ': 46,' G1 ': 49,' GS1 ': 52,' A1 ': 55,' AS1 ': 58,' BB1 ': 58,' B1 ': 62,' C2 ': 65,' CS2 ': 69, 'D2': 73, 'DS2': 78, 'EB2': 78, 'E2': 82, 'F2': 87, 'FS2': 93, 'G2': 98, 'GS2': 104, 'A2': 110, 'AS2': 117, 'BB2': 123, 'B2': 123, 'C3': 131, 'CS3': 139, 'D3': 147, 'DS3': 156, 'EB3 ': 156,' E3 ': 165,' F3 ': 175,' FS3 ': 185,' G3 ': 196,' GS3 ': 208,' A3 ': 220,' AS3 ': 233,' BB3 ': 233, 'B3': 247, 'C4': 262, 'CS4': 277, 'D4': 294, 'DS4': 311, 'EB4': 311, 'E4': 330, 'F4': 349, 'FS4': 370, 'G4': 392, 'GS4': 415, 'A4': 440, 'AS4': 466, 'BB4': 466, 'B4': 494, 'C5': 523, 'CS5 ': 554,' D5 ': 587,' DS5 ': 622,' EB5 ': 622,' E5 ': 659,' F5 ': 698,' FS5 ': 740,' G5 ': 784,' GS5 ': 831, 'A5': 880, 'AS5': 932, 'BB5': 932, 'B5': 988, 'C6': 1047, 'CS6': 1109, 'D6': 1175, 'DS6': 1245, 'EB6': 1245, 'E6': 1319, 'F6': 1397, 'FS6': 1480, 'G6': 1568, 'GS6': 1661, 'A 6 ': 1760,' AS6 ': 1865,' BB6 ': 1865,' B6 ': 1976,' C7 ': 2093,' CS7 ': 2217,' D7 ': 2349,' DS7 ': 2489,' EB7 ': 2489, 'E7': 2637, 'F7': 2794, 'FS7': 2960, 'G7': 3136, 'GS7': 3322, 'A7': 3520, 'AS7': 3729, 'BB7': 3729, 'B7': 3951, 'C8': 4186, 'CS8': 4435, 'D8': 4699, 'DS8': 4978}
def buzz (chastota, uzunlik): #"buzz" funktsiyasini yarating va uni balandligi va davomiyligi bilan ta'minlang)
agar (chastota == 0):
time.sleep (uzunlik) qaytish davri = 1.0 / chastota #chastotali kechikishValue = period / 2 #to'lqinning yarmi uchun vaqtni hisoblang sonlar = int (uzunlik * chastota) #to'lqinlar soni = i diapazonda davomiylik x chastotasi (numCycles)): #dan pastadirni boshlang buzzer_pin.on () time.sleep (delayValue) buzzer_pin.off () time.sleep (delayValue)
def play (ohang, temp, pauza, p = 0.800):
i uchun diapazonda (0, len (ohang)): # Qo`shiq notasini ijro etishDuration = temp/temp buzz (melodiya , noteDuration) # Qo`shiq notasi davomida chastotani o`zgartirish pauzaBotweenNotes = noteDuration * pauza vaqti. uxlash (pauzaBetweenNotes)
rost bo'lsa:
laserturret () tanaffus;
4 -qadam: O'yin -kulgi
O'yin -kulgi uskunalarini yaratish
Biz Simon aytadigan tugmachali o'yinni yaratamiz, u LEDlarning yonish sxemasiga amal qilishi va tegishli tugmachalarni bosishi kerak. U boshqaruv panelida keyingi foydalanish uchun ballar va vaqt tamg'asini NoSQL firebase ma'lumotlar bazasiga yuklaydi.
Zanjirlarni Fritzing diagrammasida ko'rsatilgan tarzda ulang.
O'yin -kulgi dasturini yaratish
o'yin -kulgi
import RPi. GPIO = 'h5Sis7TXdoUVncrpjSzGAvhBH' CONSUMER_SECRET = 'ZfDVxc4aTd9doGmBQO3HiSKKzxSTKT4C3g0B3AGx8eETCJm2rY' ACCESS_KEY = 'Firebase import Firebase CONSUMER_KEY dan sana import DATETIME dan vaqt import uyqudan subprocess import qo'ng'iroq dan rpi_lcd import displeyda dan GPIOimport zarrachalar import vaqt import tasodifiy import OS import tweepy sifatida 988333099669901312- YDLEQN1weW2n1JP4lxJcFPppCsbvzQh 'ACCESS_SECRET =' K2IlUPur6jx7DO5S0HhhZW29H5AQFOvkMMevSsk9ZzwLk 'auth = tweepy. OAuthHandler (CONSUMER_KEY, CONSUMER_SECRET) auth.secure = True auth.set_access_token (ACCESS_KEY, ACCESS_SECRET) API = tweepy. API (auth) Firebase = firebase. FirebaseApplication («https:// iotca2 -12f48.firebaseio.com ', Yo'q) lcd = LCD () lcd.text (' Xursand bo'ling! ', 1) lcd.text (' Omad! ', 2) uxlash (1) # Qizil, Sariq, Yashil LIGHTS = [40, 38, 36] TUGMALAR = [37, 33, 35] QAYDLAR = ["E3", "A4", "E4"] # o'zgarishi mumkin, bu o'yin tezligiga ta'sir qiladi = 0,5 # bayroqlar o'yin signallari uchun ishlatiladi. status is_displaying_pattern = Noto'g'ri is_won_curr ent_level = False is_game_over = False # o'yin holati current_level = 1 current_step_of_level = 0 model = def initialize_gpio (): GPIO.setmode (GPIO. BOARD) GPIO.setup (LIGHTS, GPIO. OUT, initial = GPIO. LOW) GPIO. (3) oralig'idagi i uchun sozlash (BUTTONS, GPIO. IN, pull_up_down = GPIO. PUD_DOWN): GPIO.add_event_detect (BUTTONS , GPIO. FALLING, verify_player_selection) def verify_player_selection (channel): global current_step_le_level_level_level_level is_game_over if is_displaying_pattern and is_won_current_level and not_game_over: flash_led_for_button (channel) if channel == BUTTONS [pattern [current_step_of_level]: current_step_of_level += 1 if current_step_vel_level_level_level_leve flash_led_for_button (button_channel): led = LIGHTS [BUTTONS.index (button_channel)] GPIO.output (led, GPIO. HIGH) time.sleep (0.4) GPIO.output (led, GPIO. LOW) def add_new_color_to_pattern (): global is_won jingalak rent_step_of_level is_won_current_level = False current_step_of_level = 0 next_color = random.randint (0, 2) pattern.append (next_color) def display_pattern_to_player (): global is_displaying_pattern is_displaying GPU: GPIO.output (LIGHTS [pattern , GPIO. HIGH) time.sleep (speed) GPIO.output (LIGHTS [pattern , GPIO. LOW) time.sleep (speed) is_displaying_pattern = Noto'g'ri def wait_for_player_to_repeat_pattern (): is_won_current_level va is_game_over emas esa: daf reset_board_for_new_game time.sleep (0,1) (): global is_displaying_pattern, is_won_current_level, is_game_over global current_level, current_step_of_level, namuna is_displaying_pattern = FALSE is_won_current_level = FALSE is_game_over = FALSE current_level = 1 current_step_of_level = 0 namuna = GPIO.output (LIGHTS, GPIO. LOW) def send_data (ball): lcd.text ('O'yin oxiri', 1) lcd.text ('Tez orada ko'rishguncha!', 2) datestr = str (datetime. now ()) while True: chop etish (datestr) print (score) data = {'Date': datestr, 'Score': score} result = firebase.post ('/scores/', data) print (result) if score> 2: status = 'Kimdir gol urdi' +(str (skor))+'ustiga'+datestr+'!' api.update_status (status = status) break start_game (): while True: add_new_color_to_pattern () display_pattern_to_player () wait_for_player_to_repeat_pattern () if is_game_over: send_data (current_level -!) bosma ("O'yin ustidan!" n).format (joriy daraja - 1)) uyqu (2) chop etish ("O'ynaganingiz uchun tashakkur! / n") lcd.text ('', 1) lcd.text ('', 2) tanaffus vaqti.sleep (2) def start_game_monitor (): t = threading. Thread (target = start_game) t.daemon = True t.start () t.join () def main (): try: os.system ('cls' if os.name == 'nt) 'else' clear ') print ("Yangi turni boshlang! / n") initialize_gpio () start_game_monitor () nihoyat: GPIO.cleanup () agar _name_ ==' _main_ ': main ()
5 -qadam: IOT App Watson IBM Bluemix -da [Birinchi qism]
Blumix IoT xizmatini o'rnating
- Shlyuz qurilmasi turini o'rnating
- Qurilmani sozlash
1 va 2 -qadamlarni 3 marta bajaring. Bitta RPi bitta bo'lim uchun (Xavfsizlik/Mudofaa/O'yin -kulgi)
Qizil tugunni o'rnating
Qizil tugunni ishlating
qizil tugunli boshlanish
- Gamburger menyusidagi palitrani boshqarish uchun o'ting (yuqori o'ngda)
-
Quyidagi paletlarni yuklab oling
- qizil tugunli boshqaruv paneli
- tugun-qizil-hissa-olov bazasi
- tugun-qizil-hissa-ibm-vatson-iot
6 -qadam: Qizil oqim tugunlari
Fayllarni yuklab oling va qizil tugunga eksport qiling.
Xavfsizlik tuguni-qizil
hech kim
Himoya Rpi tugun-qizil
laserturret.txt
O'yin-kulgi Rpi tugun-qizil
- o'yin -kulgi rpi flow.txt
- ldr rpi oqim.txt
IBM Bluemix tugun-qizil
Tavsiya:
O'yin maydonchasi Express bilan xavfsizlik birinchi dubulg'asi: 10 qadam
O'yin maydonchasi ekspressli birinchi dubulg'ali xavfsizlik: Siz velosipedda yurganmisiz va qay tomonga burilayotganingizni bildirish uchun qo'lingizni ruldan tortib olishdan xavotirlanganmisiz? Endi bu qo'rquv o'tmishda bo'lishi mumkin! Ushbu qo'llanma sizga C-dan foydalanib, dubulg'ali qo'llarsiz dubulg'alash tizimini qanday yaratishni ko'rsatib beradi
Xizmat panelidagi 8 bitli kompyuterga umumiy nuqtai: 3 qadam
Xizmat panelidagi 8-bitli kompyuterga umumiy nuqtai: Ushbu loyihadan maqsadim-kompyuter arxitekturasi, uskuna dizayni va montaj darajasidagi tillarni yaxshiroq tushunish. Kompyuter muhandisligi fakultetida kichik bo'lganim uchun men yaqinda elektronika, laboratoriya kurslarini tamomlaganman
Android ilovalarini qo'llab -quvvatlaydigan IoT uydagi ob -havo monitoringi tizimi (Mercury Droid): 11 qadam
Android ilovalarini qo'llab -quvvatlaydigan IoT uy sharoitida ob -havo monitoringi tizimi (Mercury Droid): Kirish Merkuriy Droid - bu Android mobil ilovasi bo'lgan Mercury Droid -ga asoslangan IoT (narsalar Interneti) o'rnatilgan bir turi. Qaysi o'lchash mumkin & uydagi ob -havo faolligini kuzating. Bu uydagi ob -havo monitoringi uchun juda arzon tizim
PCB dizayni va chizish bo'yicha umumiy nuqtai: 5 qadam
PCB -ni loyihalash va chizish bo'yicha umumiy nuqtai: PCB -ni loyihalash va chizishning bir necha usullari mavjud, eng oddiylaridan tortib eng murakkabigacha. Qaysi birini tanlash kerak, qaysi biri sizning ehtiyojlaringizga mos keladi, degan savolga tushunarsiz bo'lish oson
H 2 ko'prigi (293D) yordamida 2 ta tishli hobbi dvigatellari Ans Arduino; sxemaga umumiy nuqtai: 9 qadam
H 2 ko'prigi (293D) yordamida 2 tishli xobbi dvigatellari Ans Arduino; sxemaga umumiy nuqtai nazar: H ko'prik 293D - bu ikkita dvigatelni boshqarishga qodir bo'lgan integral sxemadir. 2 ta motorni ikki tomonlama (oldinga va orqaga) Kod bilan boshqarishi mumkin