Cov txheej txheem:

Bentzi Led: 3 Cov Kauj Ruam
Bentzi Led: 3 Cov Kauj Ruam

Video: Bentzi Led: 3 Cov Kauj Ruam

Video: Bentzi Led: 3 Cov Kauj Ruam
Video: Теперь твои стопы точно увидят! Умные Лампы стоп-габарит P21/5W Дилас 2024, Hlis ntuj nqeg
Anonim
Image
Image
Bentzi Coj
Bentzi Coj
Bentzi Coj
Bentzi Coj

qhov no zoo li cas thaum nws ua haujlwm

Kauj Ruam 1: Txoj Cai rau Lub Teeb

Code rau Lub Teeb
Code rau Lub Teeb

Nws yuav yog me ntsis ntxhib thaum koj saib nws los ntawm no

int greenled = 9; // teev cov xim ntsuab rau lub teeb

int blueled = 10; // teev cov xim xiav rau lub teeb int redled = 11; // teev cov xim liab rau lub teeb int redval = 0; // teeb tsa tus nqi uas tuaj yeem hloov pauv rau xim liab int blueval = 0; // teeb tsa tus nqi uas tuaj yeem hloov pauv rau xim xiav int greenval = 0; // teeb tsa tus nqi uas tuaj yeem hloov pauv rau xim ntsuab int potPin = A0; // teeb tsa tus nqi rau pententiometer tso cai rau nws ua haujlwm tsis muaj teeb tsa () {// muab koj cov cai teeb tsa ntawm no, kom khiav ib zaug: pinMode (potPin, INPUT); // los ntawm kev ua nws INPUT koj tab tom qhia rau Potpin nyeem dab tsi qhov txiaj ntsig yog pinMode (A0, INPUT); // los ntawm kev ua nws cov tswv yim nws tau qhia nws kom nyeem qhov tseem ceeb xa nws mus rau lub teeb pinMode (greenled, OUTPUT); // rau txhua lub teeb los ntawm kev qhia lawv ua OUTPUTs koj tab tom qhia lawv kom tsim xim. pinMode (redled, OUTPUT); pinMode (blueled, OUTPUT); Serial.begin (9600); // qhov no yog qhia rau Serial kom pib luam qhov tseem ceeb}

void loop () {// tso koj tus lej tseem ceeb ntawm no, kom rov ua dua: redval = analogRead (potPin); // qhov no qhia tus nqi nyeem los ntawm potpin greenval = analogRead (potPin); // qhov no qhia tus nqi nyeem los ntawm potpin blueval = analogRead (potPin); // qhov no yog qhia tus nqi nyeem los ntawm potpin redval = daim ntawv qhia (redval, 0, 1023, 255, 0); // qhov no yog qhia qhov tseem ceeb los cuam tshuam 0 rau 1023 thiab 255 rau xoom blueval = daim ntawv qhia (blueval, 0, 1023, 0, 255); // tib yam li saum toj no tsuas yog sib txawv tus lej greenval = daim ntawv qhia (greenval, 0, 1023, 130, 5); // tib yam li ob qho saum toj no xwb cov lej sib txawv Serial.print (redval); // qhia Serial luam tawm tus nqi sib npaug rau xiav thiab ntsuab Serial.print (blueval); Serial.println (greenval); analogWrite (redled, redval); // qhia lub teeb ua raws li tus nqi liab qhia nws rau analogWrite (greenled, greenval); analogWrite (blueled, blueval);

}

Kauj ruam 2: Teeb

Teeb
Teeb
Teeb
Teeb
Teeb
Teeb

ceg loj rau lub teeb mus rau tsib volts nruab nrab ceg rau pentameter mus rau A0

Kauj Ruam 3: Nws Zoo Li Cas Thaum Koj Sim Nws Thaum Kawg

Yog tias koj xav hloov cov xim rov qab mus rau txoj cai teeb tsa thiab kho cov lej thaum redvalue lossis ntsuab lossis xiav tau nyeem los ntawm daim ntawv qhia qhov tseem ceeb hloov tus lej ntawm no cov kauj ruam redval = daim ntawv qhia (redval, 0, 1023, 255, 0);

Pom zoo: