Salve a tutti, sto cercando di programmare un telecomando (per una macchinina che farò in seguito) ad infrarossi che mi invii i valori dell'asse x e y ottenuti da un accellerometro adxl345. Utilizzo la libreria di KEN SHERIFF (spero si scriva cosi) per mandare il codice tramite un led IR connesso sul pin 3. ora il codice:
Ed ora il problema: sebbene la seriale mi dia i valori corretti dell'accellerometro perchè il led rimane spento???
P.S. anticipo immediatamente che controllo l'accensione del led tramite fotocamera del cellulare.
Figurati, no problem.
Per completezza di informazione ho collegato il led IR ad una resistenza da 220 ohm, ed in seconda battuta, ho sostituito il led IR con un led rosso, ma lo stesso non funzionava.
Grazie ancora.
La IRRemote dentro la sendRaw() abilita la spedizione, ma sfrutta il timer2:
void IRsend::enableIROut(int khz) {
// Enables IR output. The khz value controls the modulation frequency in kilohertz.
// The IR output will be on pin 3 (OC2B).
// This routine is designed for 36-40KHz; if you use it for other values, it's up to you
// to make sure it gives reasonable results. (Watch out for overflow / underflow / rounding.)
// TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B
// controlling the duty cycle.
// There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A)
// To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin.
// A few hours staring at the ATmega documentation and this will all make sense.
// See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details.
// Disable the Timer2 Interrupt (which is used for receiving IR)
TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
pinMode(TIMER_PWM_PIN, OUTPUT);
digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low
TIMER_CONFIG_KHZ(khz);
}
Non è che anche la libreria del ADXL345 usa lo stesso? Dalla prova di @Brunello sembrerebbe di si.
Fai come lui, prova a togliere per il momento il codice del ADXL.
Che Arduino usi, Mega o Uno ?