Saturday, January 9, 2010

Analog Inputs

I've been fighting since late last night trying to get analog inputs working on my PIC16F684.

I finally got somewhere this evening, oddly enough for some reason, in some regions of the pot it goes really quick then just a small bit over will slow it down drastically.

All my code does is initialize everything to setup RA0 as an analog input, then it turns on the ADC waits until it's done then toggles the LED and waits the amount of time in the combination of ADRESH and ADRESL, all I had to do was put ADRESH into the integer value I had, shift it 8 positions left, then or the ADRESL in, then pass it to my wait routine.

Outside of that it's finally working, the last hiccup I had was well frankly I forgot to turn it back on after trying turning it off as a troubleshooting measure. Of Course I'll continue to plug VERSION CONTROL, had I gotten this working and decided to play a little here and there to make it say be more sensitive, I may have done myself in by messing something up, now I have no fear of that.

I am posting the code on my SVN server, and one day would like to be able to make that public so everyone can get to it, but I suspect my ISP won't like me using a web server out of my house, so I'll for now plan to upload it to Google Docs.

Below you'll find the vid of the PIC Kit 1 in action with the LED's toggling quickly then as I rotate the pot it slows down.

video

Here's the code to do it, there may be some unneeded stuff, let me know if you see anything off!

For the sake of testing I uploaded this file to YouTube and am going to see what the difference in appearance is here!