Created
January 11, 2018 16:44
-
-
Save Arthur2803/722b29301950228276e23248de075b07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| boolean trykketRiktig; | |
| long startTid; | |
| int G1=2; | |
| int G2=3; | |
| int G3=4; | |
| int R1=5; | |
| int G4=6; | |
| int G5=7; | |
| int G6=8; | |
| int R2=9; | |
| int G7=10; | |
| int G8=11; | |
| int G9=12; | |
| int R3=13; | |
| int GTid=100; | |
| int RTid=1000; | |
| void setup() | |
| { | |
| pinMode(G1,OUTPUT); | |
| pinMode(G2,OUTPUT); | |
| pinMode(G3,OUTPUT); | |
| pinMode(R1,OUTPUT); | |
| pinMode(G4,OUTPUT); | |
| pinMode(G5,OUTPUT); | |
| pinMode(G6,OUTPUT); | |
| pinMode(R2,OUTPUT); | |
| pinMode(G7,OUTPUT); | |
| pinMode(G8,OUTPUT); | |
| pinMode(G9,OUTPUT); | |
| pinMode(R3,OUTPUT); | |
| } | |
| void loop() | |
| { | |
| //start | |
| G1Blink(); | |
| G2Blink(); | |
| G3Blink(); | |
| R1Blink(); | |
| delay(200); | |
| G7Blink(); | |
| G8Blink(); | |
| G9Blink(); | |
| R3Blink(); | |
| delay(200); | |
| G4Blink(); | |
| G5Blink(); | |
| G6Blink(); | |
| R2Blink(); | |
| delay(200); | |
| G7Blink(); | |
| G8Blink(); | |
| G9Blink(); | |
| R3Blink(); | |
| delay(200); | |
| G4Blink(); | |
| G5Blink(); | |
| G6Blink(); | |
| R2Blink(); | |
| delay(200); | |
| G1Blink(); | |
| G2Blink(); | |
| G3Blink(); | |
| R1Blink(); | |
| delay(150); | |
| G4Blink(); | |
| G5Blink(); | |
| G6Blink(); | |
| R2Blink(); | |
| delay(200); | |
| G7Blink(); | |
| G8Blink(); | |
| G9Blink(); | |
| R3Blink(); | |
| delay(200); | |
| G1Blink(); | |
| G2Blink(); | |
| G3Blink(); | |
| R1Blink(); | |
| delay(120); | |
| G7Blink(); | |
| G8Blink(); | |
| G9Blink(); | |
| R3Blink(); | |
| delay(200); | |
| G1Blink(); | |
| G2Blink(); | |
| G3Blink(); | |
| R1Blink(); | |
| delay(100); | |
| G4Blink(); | |
| G5Blink(); | |
| G6Blink(); | |
| R2Blink(); | |
| delay(200); | |
| G1Blink(); | |
| G2Blink(); | |
| G3Blink(); | |
| R1Blink(); | |
| delay(90); | |
| G1Blink(); | |
| G2Blink(); | |
| G3Blink(); | |
| R1Blink(); | |
| vinn(); | |
| } | |
| //funksjonene under: R1Blink, G1Blink, G2Blink, G3Blink, G4Blink, G5Blink, G6Blink, R2Blink tap, vinn | |
| void G1Blink(){ | |
| digitalWrite(G1,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < 200) | |
| { | |
| if(analogRead(A0)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G1,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G2Blink(){ | |
| digitalWrite(G2,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A0)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G2,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G3Blink(){ | |
| digitalWrite(G3,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A0)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G3,LOW); | |
| trykketRiktig = false; | |
| } | |
| void R1Blink(){ | |
| digitalWrite(R1,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < RTid) | |
| { | |
| if(analogRead(A0)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == false) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(R1,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G4Blink(){ | |
| digitalWrite(G4,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A1)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G4,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G5Blink(){ | |
| digitalWrite(G5,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A1)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G5,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G6Blink(){ | |
| digitalWrite(G6,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A1)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G6,LOW); | |
| trykketRiktig = false; | |
| } | |
| void R2Blink(){ | |
| digitalWrite(R2,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < RTid) | |
| { | |
| if(analogRead(A1)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == false) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(R2,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G7Blink(){ | |
| digitalWrite(G7,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A2)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G7,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G8Blink(){ | |
| digitalWrite(G8,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A2)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G8,LOW); | |
| trykketRiktig = false; | |
| } | |
| void G9Blink(){ | |
| digitalWrite(G9,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < GTid) | |
| { | |
| if(analogRead(A2)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == true) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(G9,LOW); | |
| trykketRiktig = false; | |
| } | |
| void R3Blink(){ | |
| digitalWrite(R3,HIGH); | |
| startTid = millis(); | |
| while(millis() - startTid < RTid) | |
| { | |
| if(analogRead(A2)== 1023) | |
| { | |
| trykketRiktig = true; | |
| } | |
| } | |
| if(trykketRiktig == false) | |
| { | |
| tap(); | |
| } | |
| digitalWrite(R3,LOW); | |
| trykketRiktig = false; | |
| } | |
| void tap(){ | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(300); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| trykketRiktig=false; | |
| //reset(starte fra starten igjen) | |
| //er det en kommando som startet koden på nytt? | |
| } | |
| void vinn(){ | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(100); | |
| digitalWrite(G1,HIGH); | |
| digitalWrite(G2,HIGH); | |
| digitalWrite(G3,HIGH); | |
| digitalWrite(G4,HIGH); | |
| digitalWrite(G5,HIGH); | |
| digitalWrite(G6,HIGH); | |
| digitalWrite(G7,HIGH); | |
| digitalWrite(G8,HIGH); | |
| digitalWrite(G9,HIGH); | |
| digitalWrite(R1,HIGH); | |
| digitalWrite(R2,HIGH); | |
| digitalWrite(R3,HIGH); | |
| delay(100); | |
| digitalWrite(G1,LOW); | |
| digitalWrite(G2,LOW); | |
| digitalWrite(G3,LOW); | |
| digitalWrite(R1,LOW); | |
| digitalWrite(G4,LOW); | |
| digitalWrite(G5,LOW); | |
| digitalWrite(G6,LOW); | |
| digitalWrite(R2,LOW); | |
| digitalWrite(G7,LOW); | |
| digitalWrite(G8,LOW); | |
| digitalWrite(G9,LOW); | |
| digitalWrite(R3,LOW); | |
| delay(1000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment