Announcement

Collapse
No announcement yet.

Atmega 16 Project / Dust sensor [Bascom]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Atmega 16 Project / Dust sensor [Bascom]

    Hi all,

    I am doing a school electronics project with one atmega16, Lcd 16x2, 2 actuators and a couple of sensors. I am using Bascom-AVR to programme.

    I would like to ask if anyone has a code for sharp dust sensor GP2Y1010AU.

    Actually I started to work with that sensor last week. I have tested it without micro and now I'm trying to interface it with the mega16. I have done a simple code, just to see the adc changes on lcd, but it doesn't work. Im using Adc(1). See the code please. I think it would be better to use a timmer with 3rd pin( of the sensor) but I don't know how to do that. Anyone can help me please.




    $crystal = 4000000
    $regfile = "m16def.dat"


    Config Lcd = 16 * 2
    Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.6 , Rs = Portd.7

    Config Adc = Free , Prescaler = Auto

    Dim A As Long
    Dim B As Long
    Dim Total As Long


    'Config Portc.5 = Output
    Config Portc.6 = Output
    Start Adc

    Cls

    Do

    Set Portc.5
    Set Portc.6

    Waitms 0.24


    Reset Portc.5
    Reset Portc.6

    Waitms 0.24

    A = Getadc(1)
    B = Getadc(1)
    Total = A + B
    Total = Total / 2

    Home

    Lcd "ADC(1):" ; Total ; " "

    Loop
    End


    See this please:

    http://itp.nyu.edu/physcomp/sensors/Reports/GP2Y1010AU

    http://www.mil.ufl.edu/imdl/papers/IMDL_...revor/dusty.pdf --- page 18

    Thanks everyone
Working...
X