Cov txheej txheem:

ATTiny-RAT, ATTINY Powered Mini Lightfollower: 3 Kauj Ruam
ATTiny-RAT, ATTINY Powered Mini Lightfollower: 3 Kauj Ruam

Video: ATTiny-RAT, ATTINY Powered Mini Lightfollower: 3 Kauj Ruam

Video: ATTiny-RAT, ATTINY Powered Mini Lightfollower: 3 Kauj Ruam
Video: Programming the new ATtiny from Arduino using UPDI [Beginner Tutorial] 2024, Kaum ib hlis
Anonim
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower
ATTiny-RAT, ATTINY Powered Mini Lightfollower

Nyob zoo cov neeg, Nws tau ib pliag txij li thaum kuv tshaj tawm kuv cov lus qhia kawg. Nws muaj ntau yam mus nyob hauv kuv lub taub hau tam sim no tab sis kuv tau tswj hwm sau kuv li "thawj kauj ruam" nrog ATTiny-Series ntawm cov chips hauv cov lus qhia luv no rau koj.

Kuv xaj qee qhov ATTINY85 cov qauv tsuas yog vim kuv xav sim lawv:-) (txhua leej txhua tus nyiam sim khoom, puas yog?). Tom qab ntawd kuv pib kos qee lub tswv yim rau hauv kuv phau ntawv. Ua siab ncaj thawj qhov kuv tau ua yog ntsais muag LED uas ib txwm yog qhov pib zoo los tshuaj xyuas yog tias koj teeb tsa/cuab yeej siv ua haujlwm. Kuv kuj tau sim ntsuas qhov ntsuas kub thiab av noo nrog DHT22 thiab SoftwareSerial. Qhov ntawd yog qhov nyuaj vim tias DHT Cov Tsev Qiv Ntawv feem ntau yog rau 16Mhz moos (yog tias koj npaj yuav ua qee yam zoo li ntawd, txheeb xyuas yuav ua li cas prescale lub sijhawm hauv). Tab sis kuv txiav txim siab los qhia koj ib yam uas yog, zoo, tsuas yog lom zem dua. BTW: Kuv tau muab ib qho ntawm kuv cov duab kos rau koj, nws tsis yog Rembrandt tab sis nws yuav qhia koj li cas kuv tau txais qhov no (tiag tiag) lub tswv yim ruam rau hauv ib daim ntawv: -P.

Kuv tsuas yog siv yam uas kuv tau dag ib puag ncig kom ua txoj haujlwm no kom pheej yig li sai tau (rau kuv). Qhov tshwm sim ntawm qhov kev lom zem me me no yog qhov zoo me me "cov neeg ua haujlwm saib xyuas lub teeb" rau ib puag ncig 10-15 $ (3 $ rau kuv:-P)

Yog li yog tias koj txaus siab rau ATTINY koj tus kheej tsuas yog nyeem ntxiv.

BTW: thov txim rau kuv cov lus Askiv tsis zoo (Kuv tsis yog ib tus neeg hais lus)

Kauj Ruam 1: Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom

Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom
Pib Nrog ATTiny & Cov Cuab Yeej & Cov Khoom

Yam koj yuav xav tau kom pib:

- ATTiny85 nti

- Arduino UNO lossis zoo sib xws

-abreadboard nrog qee tus jumper-xaim lossis ATTINY programmer lossis ua tus programmer-shield rau Arduino koj tus kheej (txheeb cov duab txuas nrog, muaj cov txheej txheem los ntawm avdweb.nl). Kuv kuj tau ua qhov no thiab kuv zoo siab heev nrog nws qhov kev hloov pauv nkaus xwb kuv tau ua yog tias kuv tau ntxiv lub qhov (socket) rau ATTinyx4 Series (xa mus rau daim duab thiab daim duab qhia chaw).

- Arduino IDE (tau nws ntawm no)

- cov ntaub ntawv kho vajtse rau ArduinoIDE (rub tawm thiab teeb tsa lawv)

Cov Ntaub Ntawv-Txuas rau chaw ua si ncaj qha Txuas mus rau cov ntaub ntawv github kuv tau siv

- thauj Arduino li ISP kos duab rau UNO (qhov no yuav yog koj li programmer)

- ua raws cov lus qhia no (https://highlowtech.org/) lossis cov lus qhia no (los ntawm ardutronix) thiab sim "ntsais muag" kos duab (hloov kho tus lej Nr. siv ATTINY daim duab raws li kev siv! koj yuav xav tau qhov ua ntej ATTINY LED thiab ~ 220Ohm Resistor rau qhov ntawd)

Ua ib daim ntawv me me-teeb tsa los txheeb xyuas txhua yam. Yog tias koj tau ua txhua yam yog lawm LED yuav ntsais thiab koj npaj mus

Cov cuab yeej

- Soldering Iron- ib co laug cam- lub tshuab xaim me me- dremel lossis lwm yam cuab yeej siv teb (tsuas yog txiav PCB)!

Cov ntaub ntawv

prototyping PCB (~ 4cmx6cm yuav ua nws)- 2x LDR- 5x 10k Resistor (2x rau LDRs thiab 2x rau transistors BE, 1x LED)- 1x 330Ohm Resistor (1x NEOPIXELS)- 2x LDR- 1x LED (xim ntawm koj xaiv, tsis txhob siv lub log-log)- 3x NEOPIXEL WS2812- 2x Transistor (BD137 lossis zoo sib xws)- 2x Diode (1N4001 lossis zoo sib xws)- 2x micromotor (piv txwv li los ntawm Hubsan micro-quadcopter)- 1x ATTINY85 + xaiv tau (pom zoo) 8PIN IC Qhov (Socket)- 1x 1s LIPO (Kuv siv 140Ah los ntawm lub qub RC-lub nyoob hoom qav taub)- qee tus pinheaders/qhov (socket)- shrinktube (LDR vaj tse)

Cia peb pib los ntawm kev tsim kho vajtse…

Kauj ruam 2: Kho vajtse

Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse

Yog tias koj tau saib cov duab kuv tau txuas nrog, teeb tsa kho vajtse yog yooj yim zoo nkauj. Yog li yog tias koj tuaj yeem nyeem cov lej thiab siv cov hlau txuas, qhov ntawd yog ib nrab ntawm kev dag. Kuj tau saib cov duab, kuv ntxiv qee qhov ntawv rau koj.

Kuv tsis muab phiaj xwm txiav PCB, koj muaj kev ywj pheej los ua koj tus kheej tsim (muaj tswv yim thiab qhia peb koj li Tiny Bots) rau peb. Qee cov lus qhia los ntawm kuv sab:

Sim ua kom cov motors raug (saib lub kaum sab xis!) Peb tsuas yog siv lub motorshaft hloov lub log. (qhov no yuav siv hluav taws xob tsawg dua) Kuv pom zoo kom tso cov motors hauv qab lub roj teeb (qhov hnyav) thiab siv LDRs ntawm sab xub ntiag (45 ° lub kaum ntse ntse) ua ke nrog ntawm LED (Kuv sim siv qhov sib xyaw ua ke no kom tsis txhob muaj teeb meem, ntxiv xav tau kev xeem).

Ntxiv mus kuv pom zoo kom ua me me rau/tawm jumper yog li lub roj teeb yuav tsis poob uas yooj yim.

Yog tias muaj dab tsi tsis meej lossis yog koj muaj lus nug, tsuas yog nug kuv. Nws yuav tsis ua rau ntau tus senes ua thesis tawm ntawm txoj haujlwm me me no.

Kauj ruam 3: Software

Software
Software
Software
Software

1st ntawm txhua qhov rub tawm thiab teeb tsa ADAFRUIT Neopixel Library

Nov yog kuv tus lej nrog qee qhov kev piav qhia loj (kuv kuj ntxiv cov ntawv kos duab). Kuv tsis tau tawm tswv yim txhua kauj ruam vim kuv xav tias nws tsis tsim nyog.

Rub cov duab kos mus rau koj ATTiny85 thiab muaj kev lom zem nrog koj cov khoom ua si tshiab

Cov tswv yim rau "tus cwj pwm" ua haujlwm + tej zaum tus lej piv txwv zoo siab tos txais:-)

Yog tias muaj lus nug, thov hu dawb.

Kuv vam tias koj txaus siab rau kuv cov lus qhia luv luv thiab taug kev me me mus rau hauv ntiaj teb ntawm ATTINYs.

/* ATTINY85-Rata yooj yim ATTINY85 siv lub teeb pom kev zoo tom qab neeg hlau. Version 2.0, los ntawm Auer Markus */

#suav nrog

#suav nrog

// cov motors

#define LMOTOR 0 #define RMOTOR 1 // LEDs #define PIXELPIN 2 #define NUMPIXEL 3 // LDRs #define LLDR A2 #define RLDR A3

// lwm yam emo = 0; ntab calibre; boolean emostate; longmillis ntev; // txhais NeopixelsAdafruit_NeoPixel PIXEL = Adafruit_NeoPixel (NUMPIXEL, PIXELPIN, NEO_GRB + NEO_KHZ800);

void teeb tsa ()

{// nce lub moos ntxiv koj yuav ntsib qee lub sijhawm teeb meem (lub neopixel lib tau sau rau 16MHz) #if tau hais tseg (_AVR_ATtiny85_) yog (F_CPU == 16000000) clock_prescale_set (clock_div_1); #ib

// PINMODE tus pinMode (LMOTOR, OUTPUT); tus pinMode (RMOTOR, OUTPUT); pinMode (LLDR, INPUT); pinMode (LLDR, INPUT); // initialize pixels PIXEL.begin (); PIXEL.show (); ncua (500); // pib qhov tshwm sim rau (int i = 0; i

void lub voj ()

{yog (lightfollow () == 1) {sab laug (); } lwm yog (lightfollow () == 2) {txoj cai (); } lwm yog (lightfollow () == 0) {rau pem hauv ntej (); } kev xav (); }

koj lightfollow () {

int cov = 14; int tau = 0; ntab laug = 0; ntab txoj cai = 0; int cov qauv = 1; // nyeem LDRs rau (int j = 0; j <piv txwv; j ++) {

sab laug = sab laug + analogRead (LLDR); txoj cai = txoj cai + (analogRead (RLDR)*calib);

}

// xam qhov tshwm sim (qhov kev taw qhia twg yog lub teeb los ntawm?)

yog ((sab laug/piv txwv)> ((txoj cai/kuaj)+treshold)) {tshwm sim = 2;}

lwm tus yog ((sab laug/piv txwv) <((txoj cai/kuaj) -treshold)) {tshwm sim = 1;}

lwm yam {result = 0;}

rov qab los; } void rau pem hauv ntej () {// Forward analogWrite (LMOTOR, 230); analogWrite (RMOTOR, 230); PIXEL.setPixelColor (0, PIXEL. Color (0, 0, 255)); PIXEL.setPixelColor (2, PIXEL. Color (0, 0, 255)); PIXEL.show (); }

void sab laug () {

// LEFT analogWrite (LMOTOR, 150); analogWrite (RMOTOR, 255); PIXEL.setPixelColor (0, PIXEL. Color (0, 0, 255)); //PIXEL.setPixelColor(1, PIXEL. Color (75, 0, 0)); PIXEL.setPixelColor (2, PIXEL. Color (0, 100, 0)); PIXEL.show (); }

void txoj cai () {

// RIGHT analogWrite (LMOTOR, 255); analogWrite (RMOTOR, 150); PIXEL.setPixelColor (0, PIXEL. Color (0, 100, 0)); PIXEL.setPixelColor (2, PIXEL. Color (0, 0, 255)); PIXEL.show (); }

// qhov no yog rau kev sim ntxiv, sim muab qhov no rau tus kheej me ntsis:-) Kuv tab tom sim seb yuav tuaj yeem ua dab tsi, tab sis tseem tsis muaj lub tswv yim zoo.

tsis muaj kev xav () {int emotimer = 2500; int sijhawm = random (250, 750); yog (millis () - oldmillis> emotimer) {oldmillis = millis (); emo = random (1,4); } yog (millis () - oldmillis> ntev) {emostate =! emostate; } yog (emostate == muaj tseeb) {hloov (emo) {rooj plaub 1: PIXEL.setPixelColor (1, PIXEL. Color ((255), (255), (255)))); PIXEL.show (); tawg; rooj plaub 2: PIXEL.setPixelColor (1, PIXEL. Color ((255), (0), (0)))); PIXEL.show (); tawg; rooj plaub 3: PIXEL.setPixelColor (1, PIXEL. Color ((0), (255), (0)))); PIXEL.show (); tawg; default: PIXEL.setPixelColor (1, PIXEL. Color (random (0, 255), random (0, 255), random (0, 255)))); PIXEL.show (); tawg; }} lwm {PIXEL.setPixelColor (1, PIXEL. Color (25, 0, 0))); PIXEL.show (); }}

Pom zoo: