I made this circuit and the c code for an atmega8 with internal oscilator...
the link contains the zip with schematic and C code...
http://www.datafilehost.com/download-8f2fb5ed.html
please take a look on it and help me with this...
sensors circut and avr input reading... thanks
Your sensor reading methode
Your sensor reading methode doen’t work. The sensors works similar to the Devantech SRF05 sensor. To read it:
- Switch port pin to Output.
- Set HIGH for a period of time to charge the capacitor
- Switch port pin to Input
- Measure the time until the pins goes LOW (the discharge time of the capacitor).
- The longer the time, the darker the surface
You will need to calibrate the sensors (find min and max time for bright and dark surfaces) before you will get valid results.
Look at the Pololu AVR Lib for code.
thanks for your kind
thanks for your kind reply… how can I measure time? this is a little bit freaky… cause by the way it is returning an analog value. Why can not convert it simply to digital 1 and 0?
and… why should I change
and… why should I change the port direction? cause it doesn’t share the same port pin so still can’t understand…
Well, we live in an analogue
Well, we live in an analogue world, not a digital. Instead of using a QTR-1C clone you can use an analog sensor like the QTR-1A and attach the analogue sensor output to an Schmitt-trigger circuit. This will give you an digital signal, but you have to ajust the trigger level by hardware with a trimmer. Beware, the trigger level will change with ambiant light, that is the disadvantage of this solution.
You need to switch the port pin to an output to charge the capacitor.
To measure time you will need a timer. Maybe you can start without using a timer and use a counter variable incrementíng in a loop when check the input pin to go LOW.
the sensor works whitout a
the sensor works whitout a calibration etc… it simply reads 0 and 1 with no problem
thats not a problem now… I reedited the code with help of ermicro… now both PWM is working…