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
7segmenti
introduzione
Numbers appear on the 7-segment display. We need to build them one by one with the various segments.
programma
apri il programma
inizia il laboratorio
algoritmo
attrezzaggio
pin1
_segA
pin2
_segB
pin3˜
_segC
pin4
_segD
pin5˜
_segE
pin6˜
_segF
pin7
_segG
pin0
_punto
variabili
X
=
0
ciclo
SWITCH OFF (0 Volt)
_segA
SWITCH OFF (0 Volt)
_segB
SWITCH OFF (0 Volt)
_segC
SWITCH OFF (0 Volt)
_segD
SWITCH OFF (0 Volt)
_segE
SWITCH OFF (0 Volt)
_segF
SWITCH OFF (0 Volt)
_segG
write the serial input on variable
X
IF HAPPENS THAT
X
is equal to
1
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segC
IF HAPPENS THAT
X
is equal to
3
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segG
SWITCH ON (5 Volt)
_segC
SWITCH ON (5 Volt)
_segD
IF HAPPENS THAT
X
is equal to
4
SWITCH ON (5 Volt)
_segF
SWITCH ON (5 Volt)
_segG
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segC
IF HAPPENS THAT
X
is equal to
5
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segF
SWITCH ON (5 Volt)
_segG
SWITCH ON (5 Volt)
_segC
SWITCH ON (5 Volt)
_segD
IF HAPPENS THAT
X
is equal to
6
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segF
SWITCH ON (5 Volt)
_segG
SWITCH ON (5 Volt)
_segC
SWITCH ON (5 Volt)
_segD
SWITCH ON (5 Volt)
_segE
IF HAPPENS THAT
X
is equal to
7
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segC
IF HAPPENS THAT
X
is equal to
8
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segC
SWITCH ON (5 Volt)
_segD
SWITCH ON (5 Volt)
_segE
SWITCH ON (5 Volt)
_segF
SWITCH ON (5 Volt)
_segG
IF HAPPENS THAT
X
is equal to
9
SWITCH ON (5 Volt)
_segF
SWITCH ON (5 Volt)
_segG
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segC
SWITCH ON (5 Volt)
_segD
IF HAPPENS THAT
X
is equal to
0
SWITCH ON (5 Volt)
_segA
SWITCH ON (5 Volt)
_segB
SWITCH ON (5 Volt)
_segC
SWITCH ON (5 Volt)
_segD
SWITCH ON (5 Volt)
_segE
SWITCH ON (5 Volt)
_segF
wait
500
milliseconds
codice arduino
//programma: 7segmenti //******* pin ******** //******* declare ******** int X=0;//declares the variable const int pin_segA=1;//pin of _segA const int pin_segB=2;//pin of _segB const int pin_segC=3;//pin of _segC const int pin_segD=4;//pin of _segD const int pin_segE=5;//pin of _segE const int pin_segF=6;//pin of _segF const int pin_segG=7;//pin of _segG const int pin_punto=0;//pin of _punto //********** setup ********** void setup(){ Serial.begin(9600); // Initialize the serial port pinMode(pin_segA,OUTPUT); pinMode(pin_segB,OUTPUT); pinMode(pin_segC,OUTPUT); pinMode(pin_segD,OUTPUT); pinMode(pin_segE,OUTPUT); pinMode(pin_segF,OUTPUT); pinMode(pin_segG,OUTPUT); pinMode(pin_punto,OUTPUT); } //********** loop ********** void loop() { digitalWrite(pin_segA,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segE,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segF,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,LOW); // HIGH/LOW is the voltage 5V/0V) X=Serial.read(); if(X==1){ digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==3){ digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==4){ digitalWrite(pin_segF,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==5){ digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segF,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==6){ digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segF,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segE,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==7){ digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==8){ digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segE,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segF,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==9){ digitalWrite(pin_segF,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segG,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,HIGH); // HIGH/LOW is the voltage 5V/0V) } if(X==0){ digitalWrite(pin_segA,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segB,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segC,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segD,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segE,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_segF,HIGH); // HIGH/LOW is the voltage 5V/0V) } delay(500);//attendi };//end loop //powered by "Arduinomio" (C) //www.mastrohora.it
copia/incolla in Arduino
collegamenti elettrici
qui il file Fritzing
logout
Ultima modifica: Agosto 2016