Go0onies

Untitled

Dec 13th, 2023
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. // GOLDORAK_GRENDIZER_UFO DID3D CODE ARDUINO NANO
  2. // ** DID 3D // Didier Picard //ORIGINALE DESIGNER this computer code and STL isn't free FIND ON CGTRADER.COM **
  3. // INFO en PROP LES LED blanche sont A fond à 220
  4.  
  5. //time
  6. long ts=0;
  7. long tms=0;
  8. long introt=0;
  9.  
  10.  
  11. //cocpit_plafonier
  12. long tmd=1;
  13. int mdl=20; // valeur depar plafonier
  14. int mdv=1;
  15. long tfire=0;
  16. long tpfir=0;
  17. int mdcf=0;
  18. int fof=0;
  19.  
  20. // Backlight Cocpit
  21. long tmbk=0;
  22. int bkl=0;
  23. int casebk=0;
  24. float bkcos;
  25. float bklog=0.2; // vitesse de clignotement log
  26. int bkf=0;
  27.  
  28. //EYEs
  29. long teye=1;
  30. int eyel=253;
  31. int eyev=1;
  32. float eyecos;
  33.  
  34.  
  35. // CornoFulgure
  36. int caseco=0;
  37. long tco=1;
  38. int corh=0;
  39. int corb=0;
  40. int corgo=0;
  41. int corv=30;
  42. float cora=0;
  43. float corp=0;
  44. int cotmp=0;
  45. float cocos=0;
  46.  
  47. // Retrolaser
  48. int retgo=1;
  49. long rettmp=0;
  50. int retp=0;
  51. float retcos=0;
  52. int retcmp=0;
  53. int retdur=0;
  54.  
  55. // ARC reactor
  56. long tarc;
  57. int arcs=0;
  58. int arcl1=120; // arc lum 1
  59. int arcl2=0; // arc lum 2
  60. int arcl3=0; // arc lum 3
  61. float arcv=200;
  62. float arcvt=10;
  63. long tarc2=0;
  64. int fire=0;
  65. int pfire=0;
  66. int arccase=1;
  67.  
  68.  
  69. void setup() {
  70. pinMode(3, OUTPUT); // led est en sortie horne_ hight
  71. pinMode(4, OUTPUT); // led est en sortie
  72. pinMode(5, OUTPUT); // led est en sortie horn low
  73. pinMode(6, OUTPUT); // led est en sortie eyes
  74. pinMode(7, OUTPUT); // led est en sortie
  75. pinMode(8, OUTPUT); // led est en sortie
  76. pinMode(9, OUTPUT); // led est en sortie back light cocpit
  77. pinMode(10, OUTPUT); // led est en sortie Light cocpit
  78. pinMode(11, OUTPUT); // led est en sortie Retrolaser
  79. pinMode(12, OUTPUT); // led est en sortie
  80. pinMode(13, OUTPUT); // led est en sortie
  81. randomSeed(analogRead(0)); // randomize the random
  82. Serial.begin (9600);
  83.  
  84. }
  85.  
  86. void loop()
  87. {
  88. ts=millis()/1000;
  89. tms=millis();
  90. // Eyes ----
  91.  
  92. while(introt==0) // intro ==============
  93. {
  94. tms=millis();
  95. if (tms>tmd+30)
  96. {
  97. tmd=tms;
  98. eyecos=eyecos+1;if(eyecos>254){eyecos=254;}
  99. analogWrite (9,eyecos);
  100. if (eyecos>40)
  101. {
  102. bkcos=bkcos+1.5;if (bkcos>250){bkcos=254;}
  103. analogWrite (10,bkcos);
  104. }
  105. if (bkcos>40)
  106. {
  107. retcos=retcos+1;if (retcos>250){retcos=254;}
  108. analogWrite (6,retcos);
  109. }
  110. if(retcos>150){introt=1;retcos=0;eyecos=0;bkcos=0.5;retgo=0;casebk=3;mdl=200;}
  111. }
  112. }
  113.  
  114. // ---------------- EYES ----------------
  115. if ((tms>teye+5)&&(tms>10)) // routine aller retour cosinus entre 60 et 255
  116. {
  117. teye=tms;
  118. eyel=40+abs(cos(eyecos)*160);
  119. eyecos=eyecos+0.01;
  120. //if (eyel>254) {eyev=-eyev;}
  121. //if (eyel<40) {eyev=-eyev;}
  122. analogWrite (6,eyel);
  123. // Serial.print("eyel:");Serial.print(eyel); Serial.print("eyecos:");Serial.println(eyecos);
  124. }
  125.  
  126.  
  127.  
  128.  
  129. // Plafonnier Cocpit ----
  130. if ((tms>tmd+2)&&(fire==0)&&(tms>10)) // tms= temps ou ca commence au debut 10000 pour 10sec
  131. {
  132. tmd=tms;
  133. mdl=mdl+mdv;
  134. if (mdl>250) {mdv=-mdv;}
  135. if (mdl<20) {mdv=-mdv;}
  136. analogWrite (10,mdl);
  137. }
  138.  
  139. // Backlight Cocpit ------
  140. 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
  141. //casebk=3; // force case
  142. if (casebk==0) // Choix 0 Case Baklight clignote rapide
  143. {
  144. if ((tms>tmbk+30)&&(tms>10))
  145. {
  146. tmbk=tms;
  147. if (bkl<=0) {bkl=254;} else {bkl=0;}
  148. analogWrite (9,bkl);
  149. if (random(100)==1){casebk=random(0,4);}
  150. }
  151. }
  152.  
  153. if (casebk==1) // Choix 1 Case Baklight clignote strombo
  154. {
  155. if ((tms>tmbk+20)&&(tms>10))
  156. {
  157. tmbk=tms;
  158. if (bkf>22) {bkl=254;}
  159. if (bkf>25) {bkl=0;bkf=0;}
  160. bkf=bkf+1;
  161. analogWrite (9,bkl);
  162. }
  163. }
  164.  
  165. if (casebk==2) // Choix 2 Case Baklight clignote lent smoth logarithm
  166. {
  167. if ((tms>tmbk+20)&&(tms>10))
  168. {
  169. tmbk=tms;
  170. bkl=abs(log(abs(cos(bkcos)))*35);if(bkl>254){bkl=254;}
  171. bkcos=bkcos+bklog; // bklog vitesse de clignotement 0.1 moyen
  172. analogWrite (9,bkl);
  173. if (random(50)==1){bklog=random(1,15); bklog=bklog/40;} // changement de vitesse
  174.  
  175. //Serial.print("bkcos:");Serial.print(bkcos); Serial.print("bkl:");Serial.println(bkl);
  176. //Serial.println(bklog);
  177. }
  178. }
  179.  
  180. if (casebk==3) // Choix 3 Case Baklight clignote lent smoth cosinus
  181. {
  182. if ((tms>tmbk+20)&&(tms>10))
  183. {
  184. tmbk=tms;
  185. bkl=40+abs(cos(bkcos)*200);
  186. bkcos=bkcos+bklog; // bklog vitesse de clignotement 0.1 moyen
  187. analogWrite (9,bkl);
  188. if (random(50)==1){bklog=random(1,10); bklog=bklog/80;} // changement de vitesse
  189.  
  190. //Serial.print("bkcos:");Serial.print(bkcos); Serial.print("bkl:");Serial.println(bkl);
  191. //Serial.println(bklog);
  192. }
  193. }
  194.  
  195.  
  196. // ======================================= CORNOFULGURE ========================
  197.  
  198. 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
  199.  
  200. if (corgo==1) // anim cornofulgure phase 1
  201. {
  202. casebk=0; // force backlight
  203. if ((tms>tco+20)&&(tms>10))
  204. {
  205. tco=tms;
  206. if (corv>cora)
  207. {
  208. if (corh==0) {corh=corp;corb=0;} else {corh=0;corb=corp;}
  209. analogWrite (3,corb); analogWrite (5,corh);
  210. corv=0;
  211. }
  212. corv=corv+1;cora=cora-0.05;corp=corp+3;
  213. if (cora<0){cora=0;}
  214. if (corp>240){corp=240;}
  215. if (cotmp>200){corgo=2;cora=6;corv=0;corp=20;cotmp=0;}
  216. cotmp=cotmp+1;
  217. }
  218. }
  219.  
  220. if (corgo==2) // anim cornofulgure phase 2
  221. {
  222. casebk=0; // force backlight
  223. if ((tms>tco+20)&&(tms>10))
  224. {
  225. tco=tms;
  226. if (corb==0) {corb=254;} else {corb=0;}
  227. analogWrite (3,corb); analogWrite (5,corb);
  228. //corp=random(000,254);
  229. //analogWrite (3,random(000,254));analogWrite (5,random(00,254));
  230. //analogWrite (3,corp);analogWrite (5,corp);
  231. /*corp=180+abs(cos(cocos)*65);// if(corp>254){corp=254;}
  232. cocos=cocos+0.2; // vitesse de clignotement 0.1 moyen
  233. analogWrite (3,corp); analogWrite (5,corp);
  234. */
  235. if (cotmp>200){corgo=3;cotmp=0;corp=240;}
  236. cotmp=cotmp+1;
  237.  
  238. }
  239. }
  240.  
  241. if (corgo==3) // anim cornofulgure phase 3
  242. {
  243. casebk=0; // force backlight
  244. if ((tms>tco+20)&&(tms>10))
  245. {
  246. tco=tms;
  247. corp=corp-4;
  248. if (corh==0) {corh=corp;corb=0;} else {corh=0;corb=corp;}
  249. analogWrite (3,corb); analogWrite (5,corh);
  250. 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);}
  251. }
  252. }
  253.  
  254. // ======================================= retrolaser ========================
  255. if ((random(80000)==1)&&(retgo==0)&&(corgo==0)){retgo=1;retp=0;retcmp=0;retdur=(100+random(300));} // choix
  256.  
  257. if (retgo==1) // anim retrolaser phase 1
  258. {
  259. casebk=1; // force backlight
  260. if ((tms>rettmp+10)&&(tms>10))
  261. {
  262. rettmp=tms;
  263. retp=retp+3;
  264. analogWrite (11,retp);
  265. if (retp>200){retgo=2;}
  266. }
  267. }
  268.  
  269. if (retgo==2) // anim retrolaser phase 2
  270. {
  271. casebk=1; // force backlight
  272. if ((tms>rettmp+20)&&(tms>10))
  273. {
  274. rettmp=tms;
  275.  
  276. retp=50+(abs(cos(retcos)*200));if(retp>254){retp=254;}
  277. retcos=retcos+0.05;// vitesse
  278. analogWrite (11,retp);
  279. retcmp=retcmp+1;
  280. if ((retcmp>retdur)&&(retp>220)){retgo=3;retcmp=0;}
  281. //Serial.println(retp);
  282. }
  283. }
  284.  
  285. if (retgo==3) // anim retrolaser phase 3
  286. {
  287. casebk=1; // force backlight
  288. if ((tms>rettmp+20)&&(tms>10))
  289. {
  290. rettmp=tms;
  291.  
  292. retp=retp-3;
  293. analogWrite (11,retp);
  294. if (retp<3){retgo=0;retcmp=0;casebk=3;retp=2;analogWrite (11,retp);}
  295. }
  296. }
  297.  
  298. // Fin -
  299. }
Advertisement
Add Comment
Please, Sign In to add comment