non ho piu' pin digitali liberi per gestire un sensore IR posso usare un pin analogico ? se si come?
lo sketch che controlla 4 relay con un IR con lettura su pin digitale e telecomando di base è questo..
#include <IRremote.h> // use the library
int receiver = 3; // pin 1 of IR receiver to Arduino digital pin 3
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
pinMode(3, INPUT); // Pin A6 input IR
pinMode(6, OUTPUT); // a relay
pinMode(7, OUTPUT); // a relay
pinMode(8, OUTPUT); // a relay
pinMode(9, OUTPUT); // a relay
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
irrecv.resume();// receive the next value
}
if ( results.value == 0xFF30CF || results.value == 0x9716BE3F ){ //tasto 1 sul telecomando
digitalWrite(6, HIGH); // set the LED on
}
if ( results.value == 0xFF18E7 || results.value == 0x3D9AE3F7 ){ //tasto 2 sul telecomando
digitalWrite(6, LOW); // set the LED 0ff
}
if ( results.value == 0xFF10EF || results.value == 0x8C22657B ){ //tasto 1 sul telecomando
digitalWrite(7, HIGH); // set the LED on
}
if ( results.value == 0xFF38C7 || results.value == 0x488F3CBB ){ //tasto 2 sul telecomando
digitalWrite(7, LOW); // set the LED 0ff
}
if ( results.value == 0xFF42BD || results.value == 0x32CFDF7 ){ //tasto 1 sul telecomando
digitalWrite(8, HIGH); // set the LED on
}
if ( results.value == 0xFF4AB5 || results.value == 0x1BC0157B ){ //tasto 2 sul telecomando
digitalWrite(8, LOW); // set the LED 0ff
}
if ( results.value == 0xFF6897 || results.value == 0xC101E57B ){ //tasto 1 sul telecomando
digitalWrite(9, HIGH); // set the LED on
}
if ( results.value == 0xFF9867 || results.value == 0x97483BFB ){ //tasto 2 sul telecomando
digitalWrite(9, LOW); // set the LED 0ff
}
}
ho letto che i pin analogici possono essere usati anche come digitali sbaglio? ma se sostituisco il pin 3 con il pin A3 nello sketch e nei contatti non leggo niente sul monitor seriale.. tutto bianco.. dove sbaglio?