Cov txheej txheem:

Auto Lock Computer System: 4 Kauj Ruam
Auto Lock Computer System: 4 Kauj Ruam

Video: Auto Lock Computer System: 4 Kauj Ruam

Video: Auto Lock Computer System: 4 Kauj Ruam
Video: 40 отборных автотоваров с Aliexpress, которые упростят жизнь любому автовладельцу #2 2024, Kaum ib hlis
Anonim
Image
Image
Sib dhos & Upload
Sib dhos & Upload

Hauv qhov kev qhia no peb tab tom tshawb txog kev nyab xeeb ntawm lub computer screen lock. Cov txheej txheem ua haujlwm muaj lub sijhawm teeb tsa uas tuaj yeem kaw koj lub vijtsam yog tias tus neeg siv tsis tau kov tus nas lossis keyboard.

Feem ntau lub neej ntawd yog nyob ib ncig ntawm ib feeb. Yog tias koj ua raws qhov kev ua tsis raug no thiab tawm hauv koj lub khoos phis tawj mus rau qhov chaw tsis khoom ib tus neeg tuaj yeem nkag mus rau koj lub khoos phis tawj nyob rau lub sijhawm ntawd kom txog thaum lub vijtsam xauv. Yog tias koj teeb nws mus rau ob peb feeb koj yuav tau txais lub xauv npo ntau zaus thaum koj tsis tau kov lub keyboard thiab uas yog qhov tsis txaus ntseeg …

Muaj ib hnub ib tus npoj yaig ua haujlwm nug kuv tias kuv puas tuaj yeem "kho" qhov teeb meem no los ntawm qee yam khoom siv uas kaw lub computer thaum nws tsis nyob ntawd, thiab kuv ua qhov nyuaj:)

Kuv tau tshawb nrhiav ntau txoj hauv kev hauv kuv lub taub hau zoo li siv arduinos thiab ntsuas lub ntsuas cua sov infrared, PIR sensor lossis tej zaum siv lub ntsej muag pom ntawm lub khoos phis tawj, tab sis kuv tau txiav txim siab rau txoj hauv kev yooj yim dua:

Peb tab tom yuav ua ke Arduino Leonardo HID kev ua haujlwm (ua raws cov keyboard) nrog lub ntsuas ntsuas nrug deb deb kom pom tias tus neeg siv lub khoos phis tawj, yog tias tsis yog lub cuab yeej yuav xa qhov tseem ceeb ua ke los ntawm USB txhawm rau kaw lub computer.

Kauj Ruam 1: Cheeb Tsam

Vim tias qhov no yog pov thawj ntawm lub tswv yim peb yuav tsim cov cuab yeej ntawm lub khob cij

Koj yuav tsum tau:

1. Arduino Leonardo (nws tseem ceeb heev uas yuav siv Leonardo vim tias nws tuaj yeem ua raws cov keyboard)

2. HC-SR04 ultrasonic nrug deb sensor

3. 2 x 10 K kuj sib txawv resistors

4. breadboard, breadboard xov hlau

5. USB cable

6. OLED zaub (https://www.adafruit.com/product/931)

Kauj ruam 2: Sib dhos & Upload

Sib dhos & Upload
Sib dhos & Upload

Ua ntej kuaj xyuas yog tias koj muaj tag nrho cov khoom xav tau thiab Arduino IDE. Kuv yuav mus luv luv mus rau cov kauj ruam sib txuas, thiab koj tuaj yeem ua tib zoo saib ntawm cov txheej txheem fritzing txuas

Los ua ke

1. Muab Leonardo tso rau ntawm lub khob cij thiab tuav nws nrog cov roj hmab

2. muab ob qhov sib txawv resistors, OLED zaub thiab ultrasonic sensor rau ntawm lub khob cij

3. txuas thaj chaw thiab vcc's

4. txuas cov pins nruab nrab ntawm cov resistors mus rau arduino A0 thiab A1

5. txuas SDA thiab SCL ntawm cov zaub rau SDA thiab SCL cim rau ntawm Leonardo

6. txuas tus txhais thiab echo tus pin ntawm lub ntsuas ultrasonic mus rau 12, 13 tus pin digital ntawm Leonardo

7. txuas lub USB rau lub khoos phis tawj

Upload

Ua ntej tshaj plaws koj yuav tsum rub tawm thiab teeb tsa cov tsev qiv ntawv arduino tsim nyog:

1. GOFi2cOLED lub tsev qiv ntawv:

2. Lub tsev qiv ntawv Ultrasonic-HC-SR04:

Yog tias koj tsis paub yuav teeb tsa lub tsev qiv ntawv arduino txheeb xyuas qhov kev qhia no li cas.

Tom qab koj tau rub tawm thiab teeb tsa cov tsev qiv ntawv saum toj no, koj tuaj yeem clone lossis rub tawm kuv cov chaw cia khoom arduino nyob ntawm no: https://github.com/danionescu0/arduino, thiab peb yuav siv daim duab no: https://github.com/danionescu0 /arduino/tsob ntoo/tus tswv…

Lossis koj tuaj yeem luam thiab muab cov cai hauv qab no:

/ * * Cov tsev qiv ntawv siv los ntawm txoj haujlwm no: * * GOFi2cOLED: https://github.com/hramrach/GOFi2cOLED * Ultrasonic-HC-SR04: https://github.com/JRodrigoTech/Ultrasonic-HC-SR04 */#include "Keyboard.h" #include "Wire.h" #include "GOFi2cOLED.h" #include "Ultrasonic.h"

GOFi2cOLED GOFoled;

Ultrasonic ultrasonic (12, 13);

const byte distancePot = A0;

const byte timerPot = A1; const ntab feem pua MaxDistanceChangedAllowed = 25; int realDistance; unsigned ntev maxDistanceDetectionTime; bool lockTimerStarted = tsis tseeb;

void teeb tsa ()

{Serial.begin (9600); Keyboard.begin (); initializeDisplay (); }

void lub voj ()

{clearDisplay (); realDistance = tauActualDistance (); writeStatusData (); doDisplay (); yog (! lockTimerStarted && shouldEnableLockTimer ()) {lockTimerStarted = tseeb; maxDistanceDetectionTime = millis (); Serial.println ("ntsuas lub sijhawm pib"); } lwm yog (! shouldEnableLockTimer ()) {Serial.println ("xauv timer xiam oob qhab"); lockTimerStarted = tsis tseeb; } yog (shouldLockScreen ()) {lockScreen (); Serial.println ("Xauv npo"); } ncua (100); }

bool yuav tsum LockScreen ()

{rov qab lockTimerStarted && (millis () - maxDistanceDetectionTime) / 1000> getTimer (); }

bool yuav tsum EnableLockTimer ()

{int tso caiDistance = percentMaxDistanceChangedAllowed / 100 * getDistance (); return getTimer ()> 1 && getDistance ()> 1 && actualDistance - getDistance ()> tso caiDistance; }

void writeStatusData ()

{setDisplayText (1, "MinDistance:", Txoj hlua (getDistance ())); setDisplayText (1, "Timer:", Txoj hlua (getTimer ())); setDisplayText (1, "ActualDistance:", Txoj hlua (actualDistance)); int countDown = getTimer () - (millis () - maxDistanceDetectionTime) / 1000; Txoj kab lus = ""; yog (shouldLockScreen ()) {message = "xauv xa"; } lwm yog (shouldEnableLockTimer () && countDown> = 0) {message = ".." + String (countDown); } lwm {message = "tsis muaj"; } setDisplayText (1, "Xauv:", lus); }

void initializeDisplay ()

{GOFoled.init (0x3C); GOFoled.clearDisplay (); GOFoled.setCursor (0, 0); }

tsis muaj dab tsi setDisplayText (byte fontSize, String label, String data)

{GOFoled.setTextSize (fontSize); GOFoled.println (daim ntawv lo + ":" + cov ntaub ntawv); }

void doDisplay ()

{GOFoled.display (); }

tsis muaj dab tsi clearDisplay ()

{GOFoled.clearDisplay (); GOFoled.setCursor (0, 0); }

int tauActualDistance ()

{int nrugSum = 0; rau (byte i = 0; i <10; i ++) {distanceSum+= ultrasonic. Ranging (CM); }

rov qab nrugSum / 10;

}

int tauDistance ()

{xa daim duab qhia chaw (analogRead (timerPot), 0, 1024, 0, 200); }

koj getTimer ()

{xa daim duab qhia chaw (analogRead (nrug deb)), 0, 1024, 0, 20); }

void lockScreen ()

{Serial.println ("nias"); Keyboard.press (KEY_LEFT_CTRL); ncua (10); Keyboard.press (KEY_LEFT_ALT); ncua (10); Keyboard.write ('l'); ncua (10); Keyboard.releaseAll (); }

Thaum kawg txuas lub arduino lub khoos phis tawj siv lub usb cable, thiab xa cov duab kos rau hauv arduino.

Kauj ruam 3: Siv Device

Siv Tus Ntaus
Siv Tus Ntaus

Thaum lub arduino txuas nrog lub khoos phis tawj nws yuav txuas ntxiv saib xyuas qhov kev ncua deb ntawm lub ntsej muag tom ntej thiab xa qhov "xauv" lub vijtsam tseem ceeb ua ke rau lub khoos phis tawj yog tias qhov kev ncua deb nce ntxiv.

Cov cuab yeej muaj qee qhov teeb tsa:

1. Qhov ib txwm nyob deb, qhov deb tuaj yeem teeb tsa siv qhov sib txawv resistor txuas nrog A0. Qhov deb kuj tseem tshwm ntawm OLED. Thaum qhov kev ncua deb yuav nce ntxiv nrog 25% los ntawm qhov uas tau teeb tsa suav nrog yuav pib

2. Sijhawm Tawm (suav rov qab). Lub sijhawm sijhawm hauv vib nas this kuj tseem tuaj yeem teeb tsa los ntawm tus tiv thaiv txuas nrog A1. Thaum lub sijhawm tas sij hawm kaw qhov hais kom ua yuav raug xa mus

3. Xauv qhov tseem ceeb ua ke. Lub neej ntawd ntsuas phoo tseem ceeb ua ke tau teeb tsa los ua haujlwm rau Ubuntu Linux 18 (CTRL+ALT+L). Txhawm rau hloov ua ke koj yuav tsum hloov kho koj daim duab kos raws li koj li kev ua haujlwm:

4. Kev tiv thaiv sij hawm thiab nrug deb. Vim tias qhov no yog lub cuab yeej uas ua raws cov keyboard nws yog lub tswv yim zoo kom muaj lub tshuab ua haujlwm tsis ua haujlwm ntawm cov keyboard. Hauv kuv daim duab kuv tau xaiv tias lub sijhawm thiab nrug yuav tsum ntau dua yog "1". (koj tuaj yeem hloov kho qhov ntawd hauv cov cai yog tias koj nyiam)

Nrhiav thiab hloov "lockScreen ()" ua haujlwm

void lockScreen () {Serial.println ("nias"); Keyboard.press (KEY_LEFT_CTRL); ncua (10); Keyboard.press (KEY_LEFT_ALT); ncua (10); Keyboard.write ('l'); ncua (10); Keyboard.releaseAll (); }

Rau tag nrho cov npe ntawm cov yuam sij tshwj xeeb arduino, kos ntawm no:

Kauj Ruam 4: Lwm Txoj Hauv Kev

Ua ntej qhov kev coj ua no kuv tau txiav txim siab qee qhov kev coj ua ib yam nkaus:

1. Tus pas ntsuas kub infrared (MLX90614 https://www.sparkfun.com/products/10740). Tus pas ntsuas kub infrared yog ib qho cuab yeej ntsuas ntsuas kub los ntawm kev tshuaj xyuas cov duab hluav taws xob tawg tawm los ntawm ib yam khoom nyob deb li cas. Kuv muaj ib tus dag ib ncig thiab kuv xav tias tej zaum kuv tuaj yeem paub qhov txawv ntawm qhov kub thiab txias nyob rau hauv pem hauv ntej ntawm lub computer.

Kuv tau nqes nws, tab sis qhov kub sib txawv me me (thaum kuv nyob pem hauv ntej lossis tsis) 1-2 degrees thiab kuv xav tias nws tsis tuaj yeem ntseeg tau

2. PIR sensor. (https://www.sparkfun.com/products/13285) Cov ntsuas hluav taws xob pheej yig no tau ua lag luam raws li "lub suab ntsuas" tab sis lawv yeej pom qhov hloov pauv ntawm cov duab hluav taws xob infrared yog li hauv txoj kev xav nws tuaj yeem ua haujlwm, thaum ib tus neeg tawm hauv lub khoos phis tawj lub sensor yuav pom uas.. Tsis tas li cov ntsuas no muaj qhov ua kom ncua sijhawm thiab cov pob qhov rhiab heev. Yog li kuv tau nqes ib qho thiab ua si nrog nws tab sis nws zoo li lub sensor nws tsis tau ua rau thaj tsam ze (nws muaj lub dav), nws muab txhua yam kev ceeb toom cuav.

3. Nrhiav ntsej muag siv lub webcam. Qhov kev xaiv no zoo li nthuav heev, raws li kuv ua si nrog lub khoos phis tawj no hauv kuv lwm qhov haujlwm xws li: https://github.com/danionescu0/robot-camera-platfo… thiab https://github.com/danionescu0/image-processing- pr…

Nov yog daim ncuav mog qab zib! Tab sis muaj qee qhov tsis zoo: lub koob yees duab ntawm lub laptop tsis tuaj yeem siv rau lwm lub hom phiaj thaum txoj haujlwm tau ua haujlwm, thiab qee lub khoos phis tawj yuav xav tau rau qhov ntawd. Yog li kuv tau poob lub tswv yim no ib yam.

Yog tias koj muaj tswv yim ntau ntxiv txog yuav ua li cas thiaj ua tau no thov qhia rau lawv, ua tsaug!

Pom zoo: