Stap 3: programmeren.
T1 = Pin 7 = E
T2 = Pin 8 = D
T3 = Pin 9 = C
T4 = Pin 10 = G
T5 = Pin 11 = F
T6 = Pin 12 = A
T7 = Pin13 = B
De T's geven de nummers van de transistor als op de pagina voor of na deze. De A, B, C, D, E, F, G zijn gestandaardiseerde zeven segment letters. Boven heb ik zeven segment brievennamen voor uw referentie gestandaardiseerd.
Upload deze code naar de Arduino:
/* Octopi by blinkyblinky The Octopi is a device that displays one digit of pi for a certain amount of time before it repeats. Dashes define the end of the string before repeat...you could always add more digits to the string... */ //A string simplifies and complicates life. But I used one anyways. String pi = "314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778---"; int needtoloop = pi.length();//checking length of pi:-)Okay just the string... //Let's define some pins! int T1 = 7; int T2 = 8; int T3 = 9; int T4 = 10; int T5 = 11; int T6 = 12; int T7 = 13; void setup(){ pinMode (T1,OUTPUT); pinMode (T2,OUTPUT); pinMode (T3,OUTPUT); pinMode (T4,OUTPUT); pinMode (T5,OUTPUT); pinMode (T6,OUTPUT); pinMode (T7,OUTPUT); } void loop() { pinitiate(); } void pinitiate(){ //get it pi initiate? No? Oh well...back to the joke book. for (int n = 0; n < needtoloop; n++){ if (pi.charAt(n)=='0') { digitalWrite(T6, HIGH); digitalWrite(T5, HIGH); digitalWrite(T7, HIGH); digitalWrite(T1, HIGH); digitalWrite(T3, HIGH); digitalWrite(T2, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T6, LOW); digitalWrite(T5, LOW); digitalWrite(T7, LOW); digitalWrite(T1, LOW); digitalWrite(T3, LOW); digitalWrite(T2, LOW); // pinitiate(); } else if (pi.charAt(n)=='1') { digitalWrite(T7, HIGH); digitalWrite(T3, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T7, LOW); digitalWrite(T3, LOW); // pinitiate(); } else if (pi.charAt(n)=='2') { digitalWrite(T6, HIGH); digitalWrite(T7, HIGH); digitalWrite(T4, HIGH); digitalWrite(T1, HIGH); digitalWrite(T2, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T6, LOW); digitalWrite(T7, LOW); digitalWrite(T4, LOW); digitalWrite(T1, LOW); digitalWrite(T2, LOW); // pinitiate(); } else if (pi.charAt(n)=='3') { digitalWrite(T6, HIGH); digitalWrite(T7, HIGH); digitalWrite(T4, HIGH); digitalWrite(T3, HIGH); digitalWrite(T2, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T6, LOW); digitalWrite(T7, LOW); digitalWrite(T4, LOW); digitalWrite(T3, LOW); digitalWrite(T2, LOW); // pinitiate(); } else if (pi.charAt(n)=='4') { digitalWrite(T5, HIGH); digitalWrite(T4, HIGH); digitalWrite(T7, HIGH); digitalWrite(T3, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T5, LOW); digitalWrite(T4, LOW); digitalWrite(T7, LOW); digitalWrite(T3, LOW); // pinitiate(); } else if (pi.charAt(n)=='5') { digitalWrite(T6, HIGH); digitalWrite(T5, HIGH); digitalWrite(T4, HIGH); digitalWrite(T3, HIGH); digitalWrite(T2, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T6, LOW); digitalWrite(T5, LOW); digitalWrite(T4, LOW); digitalWrite(T3, LOW); digitalWrite(T2, LOW); // pinitiate(); } else if (pi.charAt(n)=='6') { digitalWrite(T6, HIGH); digitalWrite(T5, HIGH); digitalWrite(T4, HIGH); digitalWrite(T3, HIGH); digitalWrite(T2, HIGH); digitalWrite(T1, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T6, LOW); digitalWrite(T5, LOW); digitalWrite(T4, LOW); digitalWrite(T3, LOW); digitalWrite(T2, LOW); digitalWrite(T1, LOW); // pinitiate(); } else if (pi.charAt(n)=='7') { digitalWrite(T5, HIGH); digitalWrite(T6, HIGH); digitalWrite(T7, HIGH); digitalWrite(T3, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T5, LOW); digitalWrite(T6, LOW); digitalWrite(T7, LOW); digitalWrite(T3, LOW); // pinitiate(); } else if (pi.charAt(n)=='8') { digitalWrite(T1, HIGH); digitalWrite(T2, HIGH); digitalWrite(T3, HIGH); digitalWrite(T4, HIGH); digitalWrite(T5, HIGH); digitalWrite(T6, HIGH); digitalWrite(T7, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T1, LOW); digitalWrite(T2, LOW); digitalWrite(T3, LOW); digitalWrite(T4, LOW); digitalWrite(T5, LOW); digitalWrite(T6, LOW); digitalWrite(T7, LOW); // pinitiate(); } else if (pi.charAt(n)=='9') { digitalWrite(T2, HIGH); digitalWrite(T3, HIGH); digitalWrite(T4, HIGH); digitalWrite(T5, HIGH); digitalWrite(T6, HIGH); digitalWrite(T7, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T2, LOW); digitalWrite(T3, LOW); digitalWrite(T4, LOW); digitalWrite(T5, LOW); digitalWrite(T6, LOW); digitalWrite(T7, LOW); // pinitiate(); } else if (pi.charAt(n)=='-') { digitalWrite(T4, HIGH); delay(1000); //Let's give ourselves one second to read the number digitalWrite(T4, LOW); // pinitiate(); } } }