Cov txheej txheem:

Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg: 6 Kauj Ruam
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg: 6 Kauj Ruam

Video: Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg: 6 Kauj Ruam

Video: Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg: 6 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg
Txheej txheem cej luam: Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg

Txog Daim Ntawv Thov

Cov kab ke IOT no yog Kev Lom Zem Hauv Tsev thiab Kev Ruaj Ntseg.

  1. Kev ruaj ntseg

    1. Coj mus rhaub daim npav RFID thiab cov tswv yim raug cawm hauv Firebase.
    2. Yog tias tau tso cai, koj tuaj yeem nkag mus tau zoo thiab daim duab raug coj thiab muab tso rau S3
    3. Yog tias tsis tau tso cai, ntu tiv thaiv los rau hauv thiab LCD Screen yuav hais tias koj tsis tau tso cai.
  2. Kws muaj txuj ci

    1. Nias lub khawm ntawm lub dashboard.
    2. Laser Turrets yuav tawm tsam qhov tawg thiab nrawm.
  3. Kev lom zem

    1. Yog tias pom cov lus tsa suab, qhov kev ua si yuav pib.
    2. Tom qab tus neeg siv ua si qhov kev ua si, cov qhab nia raug cawm hauv Firebase.
    3. LDR qhov tseem ceeb yuav raug coj thiab tso tawm ntawm lub dashboard.

Daim ntawv thov no tuaj yeem tswj hwm thiab saib tau ntawm IBM Node-Red web server. Peb siv AWS thiab IBM Cloud Services thiab peb siv Firebase ua peb cov ntaub ntawv.

Cov ntsiab lus ntawm cov kauj ruam uas yuav piav qhia

  • Yuav tsum tau kho vajtse
  • Kev Ruaj Ntseg - Yuav ua li cas los tsim kev ruaj ntseg uas siv RFID cov tswv yim thiab cov duab paub software
  • Kev Tiv Thaiv - Yuav ua li cas los tsim lub laser turret
  • Kev Lom Zem - Yuav tsim Simon -hais qhov kev ua si li cas
  • IOT App Watson ntawm IBM Bluemix - Yuav ua li cas koom ua ke txhua lub tshuab rau hauv ib lub dashboard

Mus tom ntej thiab nkag mus rau hauv daim ntawv pdf kom piav qhia ntxaws ntxiv txog yuav tsim txoj haujlwm no li cas.

Kauj Ruam 1: Yuav Tsum Tau Kho Vajtse

Nov yog yam koj xav tau

  1. Kev ruaj ntseg

    • 1 Raspberry Pi
    • 1 LCD npo
    • 1 RFID nyeem ntawv
    • 1 PiCam
    • 2 Daim npav RFID/Nyees khawm
    • X Poj niam -> Txiv neej jumper cables
  2. Kws muaj txuj ci

    • 1 Raspberry Pi
    • 2 10 ㏀ Resistor (rau Nyees khawm)
    • 2 Micro Kev Pabcuam
    • 1 650nm Laser Transmitter Module
    • 2 Laub Khawm
    • 1 Lub suab nrov
    • 3 Cov Roj Hmab Me Me/Ties Cable (kho)
    • X Poj niam -> Txiv neej jumper cables
    • X Txuas Dhia Cables
    • 1 Transistor
    • 1 Capacitor
  3. Kev lom zem

    • 1 Raspberry Pi
    • 3 1 ㏀ Resistor (rau LEDs)
    • 1 10㏀ Resistor (rau LDR)
    • 3 LEDs (Txawv Xim)
    • 3 Nyees khawm
    • 1 Lwd
    • 1 LCD npo
    • 1 Pir Motion Sensor
    • X Poj niam -> Txiv neej jumper cables
    • X Txuas Dhia Cables

Kauj Ruam 2: Ruaj Ntseg

Kev ruaj ntseg
Kev ruaj ntseg
Kev ruaj ntseg
Kev ruaj ntseg
Kev ruaj ntseg
Kev ruaj ntseg

Tsim kev ruaj ntseg system kho vajtse

Txuas cov circuits raws li qhia hauv daim duab fritzing

Tsim kev ruaj ntseg software software

  1. Configure AWS los ntawm kev tsim ib yam
  2. Install AWS Python Library
  3. Nruab LCD Library
  4. Nruab RFID Library
  5. Teeb Firebase
  6. Teeb S3 Cia
  7. Nruab Boto ntawm Raspberry Pi
  8. Nruab AWS ClI ntawm Raspberry Pi
  9. Create AWS Credentials
  10. Configure AWS
  11. Upload security.py rau RPi
  12. Upload imagerecognition.py rau RPi

security.py yog tus lej uas yuav nyeem rfid cov tswv yim thiab txheeb xyuas seb tus neeg siv yog tus nkag los lossis tsis yog. Yog tias tus neeg siv raug lees paub, daim duab yuav raug coj mus thiab muab tso rau s3. Cov cai kuj tshaj tawm rau cov ncauj lus hauv aws MQTT

Kauj Ruam 3: Kev Tiv Thaiv

Kws muaj txuj ci
Kws muaj txuj ci
Kws muaj txuj ci
Kws muaj txuj ci
Kws muaj txuj ci
Kws muaj txuj ci

Tsim lub laser turret Hardware

  1. Peb tsim lub laser turret los ntawm kev siv 2 servos thiab 1 Laser Module
  2. Txuas cov circuits raws li qhia hauv daim duab fritzing

Tsim lub laser turret Software

Cov cai hauv qab no yuav ua rau lub laser turret tua nyob rau hauv cov lus qhia tsis raug, hauv kev tawg tawg thiab nrawm

laserturret.py

los ntawm gpiozero ntshuam LED, Buzzer, Button, Servoimport sijhawm los ntawm teeb liab ntshuam ncua ntshuam random

#LED = LED (12)

#pir = MotionSensor (19, sample_rate = 5, queue_len = 1) buzzer_pin = Buzzer (17) nres = Button (5, pull_up = False) #reset = Button (6, pull_up = False) servo1 = Servo (18) servo2 = Servo tsav (24)

def cojON ():

led.on () luam tawm ("LED nyob ntawm") def ledOFF (): led.off () luam tawm ("LED tawm")

def hluav taws ():

print ("riam phom kub") buzzer_pin.on () lub sijhawm pw tsaug zog (0.1) buzzer_pin.off ()

def laserturret (): cov

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) txhaj = 0 nthuav dav = [timeBetweenBurst, timeBetweenShots, servo1.value, servo2.value, numShots] print (nthuav dav) thaum txhaj <numshots: shot+= "1" servo1.value = "servo1start" servo2.value = "servo2start" servo1start = "servo1change" servo2start = "servo2change" hluav taws () = "" time.sleep (timebetweenshots) = "" time.sleep (timebetweenburst)

cov ntawv = {

'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 (zaus, ntev): #tsim cov haujlwm "buzz" thiab pub nws lub suab thiab sijhawm)

yog (zaus == 0):

time.sleep (ntev) lub sij hawm rov qab = 1.0 / zaus #frequency delayValue = lub sijhawm / 2 #suav lub sijhawm rau ib nrab ntawm nthwv dej numCycles = int (ntev * zaus) #num ntawm nthwv dej = duratime x freq rau kuv hauv ntau yam (numCycles)): #pib lub voj los ntawm 0 mus rau qhov sib txawv "mus" xam saum toj no buzzer_pin.on () time.sleep (delayValue) buzzer_pin.off () time.sleep (delayValue)

def ua si (suab paj nruag, tempo, ncua, nrawm = 0.800):

rau kuv hauv ntau (0, len (suab paj nruag)): # Ua si nkauj noteDuration = pace/tempo buzz (suab paj nruag , noteDuration) # Hloov zaus nrog rau zaj nkauj nco pauseBetweenNotes = noteDuration * ncua sijhawm. pauseBetweenNotes)

thaum Muaj Tseeb:

laserturret () so;

Kauj Ruam 4: Kev Lom Zem

Kev lom zem
Kev lom zem
Kev lom zem
Kev lom zem
Kev lom zem
Kev lom zem

Tsim kev lom zem Kho vajtse

Peb tsim Simon-hais tias khawm game, uas koj yuav tsum ua raws tus qauv ntawm LEDs teeb pom kev zoo thiab nias cov nyees khawm sib xws. Nws upload cov qhab nia thiab lub sij hawm mus rau hauv lub firebase NoSQL database rau kev siv ntxiv hauv cov dashboards.

Txuas cov kab hluav taws xob raws li qhia hauv daim duab Fritzing.

Tsim Kev Lom Zem Software

kev lom zem.py

ntshuam RPi. GPIO li GPIOimport threading ntshuam lub sij hawm ntshuam random ntshuam os ntshuam tweepy los ntawm rpi_lcd ntshuam LCD los ntawm subprocess ntshuam hu los ntawm lub sij hawm ntshuam pw tsaug zog los ntawm DateTime ntshuam DateTime los ntawm firebase ntshuam firebase CONSUMER_KEY = 'h5Sis7TXdoUVncrpjSzGAvhBH' CONSUMER_SECRET = 'ZfDVxc4aTd9doGmBQO3HiSKKzxSTKT4C3g0B3AGx8eETCJm2rY' ACCESS_KEY = '988333099669901312- YDLEQN1weW2n1JP4lxJcFPppCsbvzQh 'ACCESS_SECRET =' K2IlUPur6jx7DO5S0HhhZW29H5AQFOvkMMevSsk9ZzwLk 'Auth = tweepy. OAuthHandler (CONSUMER_KEY, CONSUMER_SECRET) auth.secure = Yeej muaj tseeb auth.set_access_token (ACCESS_KEY, ACCESS_SECRET) api = tweepy. API (Auth) firebase = firebase. FirebaseApplication (' https:// iotca2 -12f48.firebaseio.com ', Tsis muaj) lcd = LCD () lcd.text (' Muaj kev lom zem! ', 1) lcd.text (' Hmoov Zoo! ', 2) pw tsaug zog (1) # Liab, Daj, Ntsuab LIGHTS = [40, 38, 36] BUTTONS = [37, 33, 35] NCO NTSOOV = ["E3", "A4", "E4"] # qhov tseem ceeb koj tuaj yeem hloov pauv uas cuam tshuam rau kev ua si kev ua si = 0.5 # chij siv los teeb liab game xwm txheej is_displaying_pattern = Cuav is_won_curr ent_level = False is_game_over = False # game state current_level = 1 current_step_of_level = 0 pattern = def initialize_gpio (): GPIO.setmode (GPIO. BOARD) GPIO.setup (LIGHTS, GPIO. OUT, initial = GPIO. LOW) GPIO. teeb tsa (BUTTONS, GPIO. IN, rub_up_down = GPIO. PUD_DOWN) rau kuv hauv ntau (3): GPIO.add_event_detect (BUTTONS , GPIO. FALLING, pov thawj_player_selection) def verify_player_selection (channel): thoob ntiaj teb tam sim no_step_of_level, is_game_over yog tsis yog_displaying_pattern thiab tsis is_won_current_level thiab tsis is_game_over: flash_led_for_button (channel) yog channel == BUTTONS [pattern [current_step_of_level]: current_step_of_level += 1 yog tam sim no_step_of_lec flash_led_for_button (button_channel): coj = LIGHTS [BUTTONS.index (button_channel)] GPIO.output (coj, GPIO. HIGH) time.sleep (0.4) GPIO.output (coj, GPIO. LOW) def add_new_color_to_pattern (): ntiaj teb is_wonc, kab rent_step_of_level is_won_current_level = tsis tseeb tam sim no_step_of_level = 0 next_color = random.randint (0, 2) pattern.append (next_color) def display_pattern_to_player (): thoob ntiaj teb is_displaying_pattern is_displaying_pattern = True GPIO. Ua hauj lwm): GPIO.output (LIGHTS [qauv , GPIO. HIGH) time.sleep (speed) GPIO.output (LIGHTS [pattern , GPIO. LOW) time.sleep (speed) is_displaying_pattern = False def wait (): thaum tsis is_won_current_level thiab tsis yog_game_over: time.sleep (0.1) def reset_board_for_new_game (): thoob ntiaj teb is_displaying_pattern, is_won_current_level, is_game_over ntiaj teb no current_level, current_step_of_level, tam sim no_dev_ tam sim no GPIO.output (LIGHTS, GPIO. LOW) def send_data (qhab nia): lcd.text ('Xaus kev ua si,', 1) lcd.text ('Pom koj sai sai!', 2) datestr = str (hnub tim. tam sim no ()) thaum Tseeb: luam tawm (datestr) luam tawm (qhab nia) cov ntaub ntawv = {'Hnub tim': datestr, 'Score': tau txais txiaj ntsig} tshwm sim = firebase.post ('/cov qhab nia/', cov ntaub ntawv) luam tawm (txiaj ntsig) yog qhab nia> 2: xwm txheej = 'Ib tus neeg tau qhab nia' +(str (qhab nia))+'ntawm'+datestr+'!' api.update_status (xwm txheej = xwm txheej) tawg def start_game (): thaum muaj tseeb: ntxiv_new_color_to_pattern () display_pattern_to_player () tos_for_player_to_repeat_pattern () yog is_game_over: send_data (current_level - 1) print ("Game Over!.format (current_level - 1)) pw tsaug zog (2) luam tawm ("Ua tsaug rau kev ua si! / n") lcd.text ('', 1) lcd.text ('', 2) so time.sleep (2) def start_game_monitor (): t = threading. Thread (target = start_game) t.daemon = True t.start () t.join () def main (): sim: os.system ('cls' if os.name == 'nt 'lwm qhov tseeb') luam tawm ("Pib puag ncig tshiab! / n") initialize_gpio () start_game_monitor () thaum kawg: GPIO.cleanup () yog _name_ == '_main_': main ()

Kauj Ruam 5: IOT App Watson ntawm IBM Bluemix [Tshooj Ib]

Teeb Blumix IoT Service

  1. Teeb tsa Lub Hom Phiaj Ntaus Ntaus
  2. Teem ib Device

Ua cov kauj ruam 1 thiab 2 rau 3 zaug. Ib RPi yog rau ib ntu (Kev Ruaj Ntseg/Kev Tiv Thaiv/Kev Lom Zem)

Teeb Node-Liab

Khiav ntawm-liab

pib-liab pib

  1. Mus rau tswj palette hauv cov ntawv qhia zaub mov hamburger (sab saum toj sab xis)
  2. Rub tawm cov palletes hauv qab no

    1. ntawm-liab-dashboard
    2. ntawm-liab-contrib-firebase
    3. ntawm-liab-tshab-ibm-watson-iot

Kauj Ruam 6: Node Red Flows

Node Red Flows
Node Red Flows
Node Red Flows
Node Red Flows
Node Red Flows
Node Red Flows
Node Red Flows
Node Red Flows

Rub tawm cov ntawv thiab xa tawm mus rau koj qhov liab.

Security Node-Liab

tsis muaj

Tiv Thaiv Rpi Node-Liab

laserturret.txt

Kev Lom Zem Rpi Node-Liab

  • kev lom zem rpi flow.txt
  • ldr rpi ua.txt

IBM Bluemix Node-Liab

Pom zoo: