Im just starting my adventure with Baby Orangutan 328.
I managed to control velocity of motors on output pins and now Im trying to read from sensors. I would like to use light sensors CNY70. I connected them to analog inputs PC0, PC1 and PC2 just like shown on the picture:
Uploaded with ImageShack.us
Now I have almost no idea what I should write it Atmel Studio to actually read from sensor and for example make sensor value control my motor power. That would be awesome!
And I cant use Pololu libraries…
Thanks for your help!
Can you clarify what you mean by “And I cant use Pololu libraries…”? Do you have some sort of restriction where you cannot use our libraries? If so, what are they? Typically I would suggest using the analog_read_millivolts() or analog_read_average_millivolts() functions to read the analog inputs, but if you cannot use our libraries because of some restriction, you might try looking at them to get an idea of how they manipulate the ADC registers.
So lets say I want to use that library.
I include all these:
and then I declare:
and than i try to use it:
unsigned int light=0;
I I keep recieving this error:
Do you know what Im doing wrong?
It looks like your libraries are not installed correctly. Did you follow the AVR library installation guide? Also, the function analog_read_millivolts() is already declared in the library, so you do not need to redeclare it.
You might try looking at the Function Reference section of the Orangutan Analog-to-Digital Conversion section of the AVR Library Command Reference to familiarize yourself with the analog_read_millivolts() function.