logo elektroda
logo elektroda
X
logo elektroda

ATTiny2313 AnalogRead Not Working for LDR and PIR Sensor Project—Why?

81 12
ADVERTISEMENT
  • #1 21671942
    Jay Reyes
    Anonymous  
  • ADVERTISEMENT
  • #2 21671943
    Neil Mula
    Anonymous  
  • ADVERTISEMENT
  • #3 21671944
    jay reyes
    Anonymous  
  • #4 21671945
    Neil Mula
    Anonymous  
  • #5 21671946
    jay reyes
    Anonymous  
  • ADVERTISEMENT
  • #6 21671947
    jay reyes
    Anonymous  
  • #7 21671948
    Neil Mula
    Anonymous  
  • ADVERTISEMENT
  • #8 21671949
    jay reyes
    Anonymous  
  • #9 21671950
    jay reyes
    Anonymous  
  • #10 21671951
    Neil Mula
    Anonymous  
  • #11 21671952
    jay reyes
    Anonymous  
  • #12 21671953
    Neil Mula
    Anonymous  
  • #13 21671954
    jay reyes
    Anonymous  

Topic summary

The discussion addresses an issue with using analogRead on an ATTiny2313 microcontroller for a night-activated project involving an LDR and a PIR sensor. The project works correctly on an Arduino but fails on the ATTiny2313, where analog inputs do not function as expected, causing the LED and buzzer to activate immediately upon powering the IC. Troubleshooting steps included verifying circuit connections, testing with and without the PIR sensor, changing resistor values, and trying alternative code. The key insight revealed is that the ATTiny2313 lacks a built-in Analog-to-Digital Converter (ADC), so it cannot perform analogRead operations directly. This limitation explains why analog input readings fail on the ATTiny2313. Suggested solutions include adding an external ADC via SPI, switching to a microcontroller with built-in ADC like an ATmega, or using the PIR sensor as a digital input since it typically outputs digital signals. The LDR readings referenced (values around 500) correspond to digital bit values from ADC conversion on Arduino platforms, which the ATTiny2313 cannot replicate natively.
Summary generated by the language model.
ADVERTISEMENT