pages
home
compiler
code compiler
electronics
notes about electronics
laboratory
laboratory
Processing
Processing code compiler
Theremino
Theremino code compiler
logggin
accedi o esci
tutorials Arduino
lights
my first led turns on
led's games
an electronic dice
traffic lights
candle effect
fading effect
red-green-blue 1
red-green-blue 2
7-segment display - Countdown
7-segment display bis
sensors
sensors
Sensor and serial port
sensor PIR
ultrasonic sensor
sound
Theremin
a melody
build a note
switches
buttons
keypad
input via serial port
input via serial port 2
input remote control
input remote control 2
use of variables
custom functions
servos
a robot
a remote-controlled robot
elettronica
mechanics
Italian
handbook
pins
connections
resistors
remarkable sketches
remarkable circuits
Arduino pins
error messages
tables
colour's tables
electrical simbols
referenze on-line
reference Arduino
reference Processing
link
www.arduino.cc
fritzing.org/projects
processing.org
links
hardware
base kit
facilitated kits
advanced kits
Theremino
begins the workshop
review a workshop carried out
my account
info
link
contacts
senza_titolo
introduction
We carry out an electronic dice with seven LEDs
after an intervals of 5 seconds takes a random score.
Handworking: you can create an elegant wooden dice. Make seven 5mm holes in which to insert the LEDs.
The LEDs we number them in this way:
program
apri il programma
inizia il laboratorio
algorithm
attrezzaggio
pin7
_led7
pin6˜
_led6
pin5˜
_led5
pin4
_led4
pin3˜
_led3
pin2
_led2
pin1
_led1
variabili
X
=
0
ciclo
the variable
X
becames equal to a casual number included between
1
e
6
IF HAPPENS THAT
X
is equal to
1
SWITCH ON (5 Volt)
_led7
IF HAPPENS THAT
X
is equal to
2
SWITCH ON (5 Volt)
_led1
SWITCH ON (5 Volt)
_led6
IF HAPPENS THAT
X
is equal to
3
SWITCH ON (5 Volt)
_led1
SWITCH ON (5 Volt)
_led7
SWITCH ON (5 Volt)
_led6
IF HAPPENS THAT
X
is equal to
4
SWITCH ON (5 Volt)
_led1
SWITCH ON (5 Volt)
_led4
SWITCH ON (5 Volt)
_led3
SWITCH ON (5 Volt)
_led6
IF HAPPENS THAT
X
is equal to
5
SWITCH ON (5 Volt)
_led1
SWITCH ON (5 Volt)
_led4
SWITCH ON (5 Volt)
_led3
SWITCH ON (5 Volt)
_led6
SWITCH ON (5 Volt)
_led7
IF HAPPENS THAT
X
is equal to
6
SWITCH ON (5 Volt)
_led1
SWITCH ON (5 Volt)
_led2
SWITCH ON (5 Volt)
_led3
SWITCH ON (5 Volt)
_led4
SWITCH ON (5 Volt)
_led5
SWITCH ON (5 Volt)
_led6
wait
5000
milliseconds
SWITCH OFF (0 Volt)
_led1
SWITCH OFF (0 Volt)
_led2
SWITCH OFF (0 Volt)
_led3
SWITCH OFF (0 Volt)
_led4
SWITCH OFF (0 Volt)
_led5
SWITCH OFF (0 Volt)
_led6
SWITCH OFF (0 Volt)
_led7
wait
3000
milliseconds
Arduino code
//programma: senza_titolo //******* pin ******** //******* declare ******** const int pin_led7=7;//pin of _led7 const int pin_led6=6;//pin of _led6 const int pin_led5=5;//pin of _led5 const int pin_led4=4;//pin of _led4 const int pin_led3=3;//pin of _led3 const int pin_led2=2;//pin of _led2 const int pin_led1=1;//pin of _led1 int X=0;//declares the variable //********** setup ********** void setup(){ pinMode(pin_led7,OUTPUT); pinMode(pin_led6,OUTPUT); pinMode(pin_led5,OUTPUT); pinMode(pin_led4,OUTPUT); pinMode(pin_led3,OUTPUT); pinMode(pin_led2,OUTPUT); pinMode(pin_led1,OUTPUT); } //********** loop ********** void loop() { X=random(1,6); if(X==1){ digitalWrite(pin_led7,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==2){ digitalWrite(pin_led1,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led6,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==3){ digitalWrite(pin_led1,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led7,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led6,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==4){ digitalWrite(pin_led1,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led4,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led3,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led6,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==5){ digitalWrite(pin_led1,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led4,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led3,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led6,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led7,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==6){ digitalWrite(pin_led1,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led2,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led3,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led4,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led5,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led6,HIGH); // HIGH/LOW is the voltage 5V/0V) } delay(5000);//attendi //******************************** digitalWrite(pin_led1,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led2,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led3,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led4,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led5,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led6,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_led7,LOW); // HIGH/LOW is the voltage 5V/0V) delay(3000);//attendi };//end loop //powered by "Arduinomio" (C) //www.mastrohora.it
copy/past in Arduino
electrical connections
here Fritzing's file
logout
Ultima modifica: Agosto 2016