var dg1 = A8; var dg2 = B7; var A = B14; var B = B13; var C = B10; var D = B1; var E = A7; var F = A6; var G = A5; var DP = B15; function allClear() { digitalWrite(A , 0); digitalWrite(B , 0); digitalWrite(C , 0); digitalWrite(D , 0); digitalWrite(E , 0); digitalWrite(F , 0); digitalWrite(G , 0); digitalWrite(DP , 0); digitalWrite(A8, 1); digitalWrite(B7, 1); } /* A little help? ----A---- | | F B | | ----G---- | | E C | | ----D---- */ function one() { digitalWrite(F, 1); digitalWrite(E, 1); } function two() { digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(G, 1); digitalWrite(E, 1); digitalWrite(D, 1); } function three() { digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(G, 1); digitalWrite(C, 1); digitalWrite(D, 1); } function four() { digitalWrite(F, 1); digitalWrite(G, 1); digitalWrite(B, 1); digitalWrite(C, 1); } function five() { digitalWrite(A, 1); digitalWrite(F, 1); digitalWrite(G, 1); digitalWrite(C, 1); digitalWrite(D, 1); } function six() { digitalWrite(A, 1); digitalWrite(F, 1); digitalWrite(E, 1); digitalWrite(G, 1); digitalWrite(C, 1); digitalWrite(D, 1); } function seven() { digitalWrite(F, 1); digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(C, 1); } function eight() { digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(C, 1); digitalWrite(D, 1); digitalWrite(E, 1); digitalWrite(F, 1); digitalWrite(G, 1); } function nine() { digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(C, 1); digitalWrite(G, 1); digitalWrite(F, 1); } function zero() { digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(C, 1); digitalWrite(D, 1); digitalWrite(E, 1); digitalWrite(F, 1); } function aa() { digitalWrite(A, 1); digitalWrite(B, 1); digitalWrite(C, 1); digitalWrite(E, 1); digitalWrite(F, 1); digitalWrite(G, 1); } function bb() { digitalWrite(C, 1); digitalWrite(D, 1); digitalWrite(E, 1); digitalWrite(F, 1); digitalWrite(G, 1); } function cc() { digitalWrite(A, 1); digitalWrite(F, 1); digitalWrite(E, 1); digitalWrite(D, 1); } function data() { full=(new Date()).toString(); words = full.split(' '); month = words[1]; date = words[2]; bigtime = words[4]; small = words[4].split(':'); hour = small[0]; if (hour > 12) { hour = hour-12; } min = small[1]; } /* digitalWrite(A8, 1); digitalWrite(B7, 0); three(); allClear(); digitalWrite(A8, 0); digitalWrite(B7, 1); five(); allClear(); */ function hourDriver() { data(); switch (Number(hour)) { case 00: case 12: allClear();digitalWrite(A8, 0); cc(); break; case 01: allClear();digitalWrite(A8, 0); one(); break; case 02: allClear();digitalWrite(A8, 0); two(); break; case 03: allClear();digitalWrite(A8, 0); three(); break; case 04: allClear();digitalWrite(A8, 0); four(); break; case 05: allClear();digitalWrite(A8, 0); five(); break; case 06: allClear();digitalWrite(A8, 0); six(); break; case 07: allClear();digitalWrite(A8, 0); seven(); break; case 08: allClear();digitalWrite(A8, 0); eight(); break; case 09: allClear();digitalWrite(A8, 0); nine(); break; case 10: allClear();digitalWrite(A8, 0); aa(); break; case 11: allClear();digitalWrite(A8, 0); bb(); break; } } function minuteDriver() { data(); switch(Number(min)) { case 00: case 01: case 02: case 03: case 04: allClear();digitalWrite(B7, 0); break; case 05: case 06: case 07: case 08: case 09: allClear();digitalWrite(B7, 0); digitalWrite(G, 1); break; case 10: case 11: case 12: case 13: case 14: allClear();digitalWrite(B7, 0); digitalWrite(F, 1); break; case 15: case 16: case 17: case 18: case 19: allClear();digitalWrite(B7, 0); digitalWrite(F, 1); digitalWrite(G, 1); break; case 20: case 21: case 22: case 23: case 24: allClear();digitalWrite(B7, 0); digitalWrite(A, 1); break; case 25: case 26: case 27: case 28: case 29: allClear();digitalWrite(B7, 0); digitalWrite(A, 1); digitalWrite(G, 1); break; case 30: case 31: case 32: case 33: case 34: allClear();digitalWrite(B7, 0); digitalWrite(B, 1); break; case 35: case 36: case 37: case 38: case 39: allClear();digitalWrite(B7, 0); digitalWrite(B, 1); digitalWrite(G, 1); break; case 40: case 41: case 42: case 43: case 44: allClear();digitalWrite(B7, 0); digitalWrite(C, 1); break; case 45: case 46: case 47: case 48: case 49: allClear();digitalWrite(B7, 0); digitalWrite(C, 1); digitalWrite(G, 1); break; case 50: case 51: case 52: case 53: case 54: allClear();digitalWrite(B7, 0); digitalWrite(D, 1); break; case 55: case 56: case 57: case 58: case 59: allClear();digitalWrite(B7, 0); digitalWrite(D, 1); digitalWrite(G, 1); break; } } function random(state) { if (state === true || state === 1) { clearTimeout(); random(); } else if (state === false || state === 0) { allClear(); clearTimeout(); setDeepSleep(1); return; } var what = Math.floor((Math.random() * 3)); if (what === 0) { allClear(); } else if (what == 1 || what == 2) { digitalWrite(A, Math.floor((Math.random() * 2))); digitalWrite(B, Math.floor((Math.random() * 2))); digitalWrite(C, Math.floor((Math.random() * 2))); digitalWrite(D, Math.floor((Math.random() * 2))); digitalWrite(E, Math.floor((Math.random() * 2))); digitalWrite(F, Math.floor((Math.random() * 2))); digitalWrite(G, Math.floor((Math.random() * 2))); } setTimeout(random, ((Math.random() * 1000) + 1)); } function swirl() { for (delay=35;delay>0;delay=delay-2) { digitalWrite(B14, 0); digitalWrite(B13, 1); digitalPulse(A1, 1, delay); digitalWrite(B13, 0); digitalWrite(B10, 1); digitalPulse(A1, 1, delay); digitalWrite(B10, 0); digitalWrite(B1, 1); digitalPulse(A1, 1, delay); digitalWrite(B1, 0); digitalWrite(A7, 1); digitalPulse(A1, 1, delay); digitalWrite(A7, 0); digitalWrite(A6, 1); digitalPulse(A1, 1, delay); digitalWrite(A6, 0); digitalWrite(B14, 1); digitalPulse(A1, 1, delay); } digitalWrite(B14, 0); for (i=0;i<8;i++){ digitalWrite(D, 0); digitalWrite(A, 1); digitalPulse(A1, 1, 90); digitalWrite(A, 0); digitalWrite(G, 1); digitalPulse(A1, 1, 90); digitalWrite(G, 0); digitalWrite(D, 1); digitalPulse(A1, 1, 90); } } //var l = false; //setWatch( function(e) { l=!l; random(l);}, B8, {repeat:true, edge:'falling', debounce:100}); function onInit() { data(); digitalWrite(A8,0); digitalWrite(B7,0); swirl(); digitalWrite(D, 0); setDeepSleep(1); } pinMode(B8, 'input_pullup'); pinMode(B5, 'input_pullup'); setWatch(function (e) { data(); for(i=0;i<60;i++){hourDriver();minuteDriver();} allClear(); setDeepSleep(1); }, B8, {edge:"falling", repeat:true, debounce:50}); /* var state = false; setWatch(function (e) { state=!state; random(state); setDeepSleep(1); }, B5, {edge:"falling", repeat:true, debounce:50}); */ setInterval(function(e) { data(); }, 1800000); setDeepSleep(1); save();
@BootySnorkeler started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.