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
remote2
introduction
a simple example
program
apri il programma
inizia il laboratorio
algorithm
attrezzaggio
pin0
_ricevitoreIR
pin1
_ledblue
pin2
_ledgreen
pin3˜
_ledred
pin4
_ledyellow
variabili
X
=
0
ciclo
the variable
X
is equal to... read the sensor:
_ricevitoreIR
IF HAPPENS THAT
X
is equal to
-376
SWITCH ON (5 Volt)
_ledblue
SWITCH OFF (0 Volt)
_ledgreen
SWITCH OFF (0 Volt)
_ledred
SWITCH OFF (0 Volt)
_ledyellow
IF HAPPENS THAT
X
is equal to
-12564
SWITCH OFF (0 Volt)
_ledblue
SWITCH ON (5 Volt)
_ledgreen
SWITCH OFF (0 Volt)
_ledred
SWITCH OFF (0 Volt)
_ledyellow
IF HAPPENS THAT
X
is equal to
-31764
SWITCH OFF (0 Volt)
_ledblue
SWITCH OFF (0 Volt)
_ledgreen
SWITCH ON (5 Volt)
_ledred
SWITCH OFF (0 Volt)
_ledyellow
IF HAPPENS THAT
X
is equal to
3494
SWITCH OFF (0 Volt)
_ledblue
SWITCH OFF (0 Volt)
_ledgreen
SWITCH OFF (0 Volt)
_ledred
SWITCH ON (5 Volt)
_ledyellow
wait
100
milliseconds
Arduino code
//programma: remote2 //******* pin ******** //******* declare ******** #include
; //library to work with the infraredconst int pin_ricevitoreIR=0;//pin IR receiver IRrecv irrecv(pin_ricevitoreIR); //imposto il pin all'oggetto irrecv, istanza della classe IRrecv decode_results risultati;//I merged the decoding in the variable risultati const int pin_ledblue=1;//pin of _ledblue const int pin_ledgreen=2;//pin of _ledgreen const int pin_ledred=3;//pin of _ledred int X=0;//declares the variable const int pin_ledyellow=4;//pin of _ledyellow //********** setup ********** void setup(){ irrecv.enableIRIn(); //enable IR receiver pinMode(pin_ledblue,OUTPUT); pinMode(pin_ledgreen,OUTPUT); pinMode(pin_ledred,OUTPUT); pinMode(pin_ledyellow,OUTPUT); } //********** loop ********** void loop() { if (irrecv.decode(&risultati)) { //controllo se il segnale di decodifica è valido X=risultati.value; //legge il valore decodificato irrecv.resume(); //rimette il ricevitore nella condizione di attesa del segnale successivo } if(X==-376){ digitalWrite(pin_ledblue,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledgreen,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledred,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledyellow,LOW); // HIGH/LOW is the voltage 5V/0V) } if(X==-12564){ digitalWrite(pin_ledblue,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledgreen,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledred,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledyellow,LOW); // HIGH/LOW is the voltage 5V/0V) } if(X==-31764){ digitalWrite(pin_ledblue,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledgreen,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledred,HIGH); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledyellow,LOW); // HIGH/LOW is the voltage 5V/0V) } if(X==3494){ digitalWrite(pin_ledblue,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledgreen,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledred,LOW); // HIGH/LOW is the voltage 5V/0V) digitalWrite(pin_ledyellow,HIGH); // HIGH/LOW is the voltage 5V/0V) } delay(100);//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