| Swordfish Tutorial - ADC (Control LED Blink Speed) |
|
|
| Saturday, 04 April 2009 08:22 | |
|
This tutorial/example covers another quick guide on how to use Analogue to Digital conversions with a PIC micro. It's achieved by interfacing with a 1K potentiometer to determine how fast the LED will blink. Some other aspects covered in this example include the use of the 18F4550 with the internal oscillator and basic function use.
Simulation video of circuit
Basically the PIC micro will sample AN0 (PORTA.0) and get a reading from 0 to 1023 (0V to 5V). From there, I use the DelaymS command to alter the time that the LED is on and off for. Its very basic, but does cover a couple of underlying features such as the use of a function;
Device = 18F2550 // Setup the device/clock information Clock = 8 Config FOSC = INTOSCIO_EC Include "ADC.bas" // Include the ADC.bas library Dim LED as PORTC.0 // Declare the LED pin function Get_ADC_Sample() as word // Function to grab the ADC sample result = ADC.Read(0) // Grab an ADC sample from channel 0 result = result * 2 // Scale the answer up by a factor of 2 end function OSCCON = %01110110 // Setup the internal OSC for 8Mhz Input(PORTA.0) // Make AN0 an input While True // Create an infinate loop High(LED) // Make the LED pin High Delayms(100 + Get_ADC_Sample) // Delay for 0.1 seconds + the ADC result Low(LED) // Make the LED pin Low Delayms(100 + Get_ADC_Sample) // Delay for 0.1 seconds + the ADC result Wend
Comments (2)
Joomla components by Compojoom
|
|
| Last Updated ( Tuesday, 13 October 2009 09:32 ) |
Whos Online
- Jon Chandler
- andyo
Forum Activity
REALISTIC LED candle flicker - mrdeb Wednesday, 10 March 2010 05:48 - [0 replies]
the LCD demo hello world - mrdeb Wednesday, 10 March 2010 05:41 - [29 replies]
USB problem - jon chandler Tuesday, 09 March 2010 11:31 - [3 replies]
Servo Module - andyo Tuesday, 09 March 2010 03:39 - [3 replies]
pic to ps2 communication - roshan Friday, 05 March 2010 01:30 - [7 replies]
Way Off Topic: Worldwide Ignite Week - jon chandler Wednesday, 03 March 2010 20:33 - [4 replies]
PIC USB with C and Visual C++ Project - hop Tuesday, 02 March 2010 21:49 - [0 replies]
Recent Comments
- 2010-03-05 13:24:23 mrpse...
I was thinking of battery with powered routers or powered for every...
- 2010-03-05 12:17:40 andyo
50 rooms - wow. The XBee modules are very easy to use but I'm not ...
- 2010-03-05 11:46:37 mrpse...
Thanks AndyO. What I have to do is design a device to monitor temp...
- 2010-03-05 03:08:58 andyo
The circuit used for the remote sensor can be found here: [url]http...
- 2010-03-04 07:19:06 renno
plz i need help do u know from where i could download it or how cou...
- 2010-03-04 07:16:05 renno
hello everyone i'm trying to finish my final project and i want to ...
- 2010-03-04 02:49:38 Saira...
Thanks that was helpful
- 2010-03-04 02:35:35 Jon C...
There is a BlueTooth module available. If you used this, you can s...




I plan to build a Therminine?? (musical instrument using photo transistors)
using this ADC several resistors instead of cDS (tooo slow to respond)in an array thus making numerious voltage dividers.
saw similar on HACK A DAY site