//Arduino code by Davuzz11 //Led dice With Arduino //For question write in my Instructables //Led pins int pinLeds1 = 10; int pinLeds2 = 9; int pinLeds3 = 7; int pinLed4 = 8; //Button pin int buttonPin = 6; int buttonState; //Ran will be randomized from 1 to 6 long ran; //Time is the time of delay int time = 2000; void setup () { //Set the pins of the leds as Output pinMode (pinLeds1, OUTPUT); pinMode (pinLeds2, OUTPUT); pinMode (pinLeds3, OUTPUT); pinMode (pinLed4, OUTPUT); //Set the pin of the button as an Input pinMode (buttonPin, INPUT); //This code line is necessary for a correct random randomSeed(analogRead(0)); } void loop() { //Read the status of the button buttonState = digitalRead(buttonPin); if (buttonState == HIGH){ //Randomize from 1 to 6 ran = random(7); //Number 1! if (ran == 1){ digitalWrite (pinLed4, HIGH); delay (time); } //Number 2!! if (ran == 2){ digitalWrite (pinLeds1, HIGH); delay (time); } //Number 3!!! if (ran == 3){ digitalWrite (pinLeds3, HIGH); digitalWrite (pinLed4, HIGH); delay (time); } //Number 4!!!! if (ran == 4){ digitalWrite (pinLeds1, HIGH); digitalWrite (pinLeds3, HIGH); delay (time); } //Number 5!!!!! if (ran == 5){ digitalWrite (pinLeds1, HIGH); digitalWrite (pinLeds3, HIGH); digitalWrite (pinLed4, HIGH); delay (time); } //Number 6!!!!!! if (ran == 6){ digitalWrite (pinLeds1, HIGH); digitalWrite (pinLeds2, HIGH); digitalWrite (pinLeds3, HIGH); delay (time); } } //If the button is not pressed, sets off the leds digitalWrite (pinLeds1, LOW); digitalWrite (pinLeds2, LOW); digitalWrite (pinLeds3, LOW); digitalWrite (pinLed4, LOW); } //....Finish!