Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GOLDORAK_GRENDIZER_UFO DID3D CODE ARDUINO NANO
- // ** DID 3D // Didier Picard //ORIGINALE DESIGNER this computer code and STL isn't free FIND ON CGTRADER.COM **
- // INFO en PROP LES LED blanche sont A fond à 220
- //time
- long ts=0;
- long tms=0;
- long introt=0;
- //cocpit_plafonier
- long tmd=1;
- int mdl=20; // valeur depar plafonier
- int mdv=1;
- long tfire=0;
- long tpfir=0;
- int mdcf=0;
- int fof=0;
- // Backlight Cocpit
- long tmbk=0;
- int bkl=0;
- int casebk=0;
- float bkcos;
- float bklog=0.2; // vitesse de clignotement log
- int bkf=0;
- //EYEs
- long teye=1;
- int eyel=253;
- int eyev=1;
- float eyecos;
- // CornoFulgure
- int caseco=0;
- long tco=1;
- int corh=0;
- int corb=0;
- int corgo=0;
- int corv=30;
- float cora=0;
- float corp=0;
- int cotmp=0;
- float cocos=0;
- // Retrolaser
- int retgo=1;
- long rettmp=0;
- int retp=0;
- float retcos=0;
- int retcmp=0;
- int retdur=0;
- // ARC reactor
- long tarc;
- int arcs=0;
- int arcl1=120; // arc lum 1
- int arcl2=0; // arc lum 2
- int arcl3=0; // arc lum 3
- float arcv=200;
- float arcvt=10;
- long tarc2=0;
- int fire=0;
- int pfire=0;
- int arccase=1;
- void setup() {
- pinMode(3, OUTPUT); // led est en sortie horne_ hight
- pinMode(4, OUTPUT); // led est en sortie
- pinMode(5, OUTPUT); // led est en sortie horn low
- pinMode(6, OUTPUT); // led est en sortie eyes
- pinMode(7, OUTPUT); // led est en sortie
- pinMode(8, OUTPUT); // led est en sortie
- pinMode(9, OUTPUT); // led est en sortie back light cocpit
- pinMode(10, OUTPUT); // led est en sortie Light cocpit
- pinMode(11, OUTPUT); // led est en sortie Retrolaser
- pinMode(12, OUTPUT); // led est en sortie
- pinMode(13, OUTPUT); // led est en sortie
- randomSeed(analogRead(0)); // randomize the random
- Serial.begin (9600);
- }
- void loop()
- {
- ts=millis()/1000;
- tms=millis();
- // Eyes ----
- while(introt==0) // intro ==============
- {
- tms=millis();
- if (tms>tmd+30)
- {
- tmd=tms;
- eyecos=eyecos+1;if(eyecos>254){eyecos=254;}
- analogWrite (9,eyecos);
- if (eyecos>40)
- {
- bkcos=bkcos+1.5;if (bkcos>250){bkcos=254;}
- analogWrite (10,bkcos);
- }
- if (bkcos>40)
- {
- retcos=retcos+1;if (retcos>250){retcos=254;}
- analogWrite (6,retcos);
- }
- if(retcos>150){introt=1;retcos=0;eyecos=0;bkcos=0.5;retgo=0;casebk=3;mdl=200;}
- }
- }
- // ---------------- EYES ----------------
- if ((tms>teye+5)&&(tms>10)) // routine aller retour cosinus entre 60 et 255
- {
- teye=tms;
- eyel=40+abs(cos(eyecos)*160);
- eyecos=eyecos+0.01;
- //if (eyel>254) {eyev=-eyev;}
- //if (eyel<40) {eyev=-eyev;}
- analogWrite (6,eyel);
- // Serial.print("eyel:");Serial.print(eyel); Serial.print("eyecos:");Serial.println(eyecos);
- }
- // Plafonnier Cocpit ----
- if ((tms>tmd+2)&&(fire==0)&&(tms>10)) // tms= temps ou ca commence au debut 10000 pour 10sec
- {
- tmd=tms;
- mdl=mdl+mdv;
- if (mdl>250) {mdv=-mdv;}
- if (mdl<20) {mdv=-mdv;}
- analogWrite (10,mdl);
- }
- // Backlight Cocpit ------
- if ((random(50000)==1)&&(tms>10)){casebk=random(0,4);} // choix random (1 de plus que le nb de choix) de l'anim backlight cocpit
- //casebk=3; // force case
- if (casebk==0) // Choix 0 Case Baklight clignote rapide
- {
- if ((tms>tmbk+30)&&(tms>10))
- {
- tmbk=tms;
- if (bkl<=0) {bkl=254;} else {bkl=0;}
- analogWrite (9,bkl);
- if (random(100)==1){casebk=random(0,4);}
- }
- }
- if (casebk==1) // Choix 1 Case Baklight clignote strombo
- {
- if ((tms>tmbk+20)&&(tms>10))
- {
- tmbk=tms;
- if (bkf>22) {bkl=254;}
- if (bkf>25) {bkl=0;bkf=0;}
- bkf=bkf+1;
- analogWrite (9,bkl);
- }
- }
- if (casebk==2) // Choix 2 Case Baklight clignote lent smoth logarithm
- {
- if ((tms>tmbk+20)&&(tms>10))
- {
- tmbk=tms;
- bkl=abs(log(abs(cos(bkcos)))*35);if(bkl>254){bkl=254;}
- bkcos=bkcos+bklog; // bklog vitesse de clignotement 0.1 moyen
- analogWrite (9,bkl);
- if (random(50)==1){bklog=random(1,15); bklog=bklog/40;} // changement de vitesse
- //Serial.print("bkcos:");Serial.print(bkcos); Serial.print("bkl:");Serial.println(bkl);
- //Serial.println(bklog);
- }
- }
- if (casebk==3) // Choix 3 Case Baklight clignote lent smoth cosinus
- {
- if ((tms>tmbk+20)&&(tms>10))
- {
- tmbk=tms;
- bkl=40+abs(cos(bkcos)*200);
- bkcos=bkcos+bklog; // bklog vitesse de clignotement 0.1 moyen
- analogWrite (9,bkl);
- if (random(50)==1){bklog=random(1,10); bklog=bklog/80;} // changement de vitesse
- //Serial.print("bkcos:");Serial.print(bkcos); Serial.print("bkl:");Serial.println(bkl);
- //Serial.println(bklog);
- }
- }
- // ======================================= CORNOFULGURE ========================
- if ((random(200000)==1)&&(corgo==0)&&(retgo==0)){corgo=1;corv=0;cora=6;corp=20;} // choix random (1 de plus que le nb de choix) lance le cornofulgure
- if (corgo==1) // anim cornofulgure phase 1
- {
- casebk=0; // force backlight
- if ((tms>tco+20)&&(tms>10))
- {
- tco=tms;
- if (corv>cora)
- {
- if (corh==0) {corh=corp;corb=0;} else {corh=0;corb=corp;}
- analogWrite (3,corb); analogWrite (5,corh);
- corv=0;
- }
- corv=corv+1;cora=cora-0.05;corp=corp+3;
- if (cora<0){cora=0;}
- if (corp>240){corp=240;}
- if (cotmp>200){corgo=2;cora=6;corv=0;corp=20;cotmp=0;}
- cotmp=cotmp+1;
- }
- }
- if (corgo==2) // anim cornofulgure phase 2
- {
- casebk=0; // force backlight
- if ((tms>tco+20)&&(tms>10))
- {
- tco=tms;
- if (corb==0) {corb=254;} else {corb=0;}
- analogWrite (3,corb); analogWrite (5,corb);
- //corp=random(000,254);
- //analogWrite (3,random(000,254));analogWrite (5,random(00,254));
- //analogWrite (3,corp);analogWrite (5,corp);
- /*corp=180+abs(cos(cocos)*65);// if(corp>254){corp=254;}
- cocos=cocos+0.2; // vitesse de clignotement 0.1 moyen
- analogWrite (3,corp); analogWrite (5,corp);
- */
- if (cotmp>200){corgo=3;cotmp=0;corp=240;}
- cotmp=cotmp+1;
- }
- }
- if (corgo==3) // anim cornofulgure phase 3
- {
- casebk=0; // force backlight
- if ((tms>tco+20)&&(tms>10))
- {
- tco=tms;
- corp=corp-4;
- if (corh==0) {corh=corp;corb=0;} else {corh=0;corb=corp;}
- analogWrite (3,corb); analogWrite (5,corh);
- if (corp<1){corgo=0;cora=7;corv=0;corp=20;cotmp=0;corb=0;corh=0;casebk=3;analogWrite (3,corb); analogWrite (5,corh);}
- }
- }
- // ======================================= retrolaser ========================
- if ((random(80000)==1)&&(retgo==0)&&(corgo==0)){retgo=1;retp=0;retcmp=0;retdur=(100+random(300));} // choix
- if (retgo==1) // anim retrolaser phase 1
- {
- casebk=1; // force backlight
- if ((tms>rettmp+10)&&(tms>10))
- {
- rettmp=tms;
- retp=retp+3;
- analogWrite (11,retp);
- if (retp>200){retgo=2;}
- }
- }
- if (retgo==2) // anim retrolaser phase 2
- {
- casebk=1; // force backlight
- if ((tms>rettmp+20)&&(tms>10))
- {
- rettmp=tms;
- retp=50+(abs(cos(retcos)*200));if(retp>254){retp=254;}
- retcos=retcos+0.05;// vitesse
- analogWrite (11,retp);
- retcmp=retcmp+1;
- if ((retcmp>retdur)&&(retp>220)){retgo=3;retcmp=0;}
- //Serial.println(retp);
- }
- }
- if (retgo==3) // anim retrolaser phase 3
- {
- casebk=1; // force backlight
- if ((tms>rettmp+20)&&(tms>10))
- {
- rettmp=tms;
- retp=retp-3;
- analogWrite (11,retp);
- if (retp<3){retgo=0;retcmp=0;casebk=3;retp=2;analogWrite (11,retp);}
- }
- }
- // Fin -
- }
Advertisement
Add Comment
Please, Sign In to add comment