| Swordfish Tutorial - LED |
|
|
| Saturday, 04 April 2009 07:08 | |
|
LED's are great as indicators, and are very easy to interface with. PIC's can produce around 25mA on an output. This is much more than most logic outputs will deliver, and it helps to interface with many devices, especially simple LED's that only require 5mA-20mA usually.
Here's a simple program that will turn an LED on and off twice a second in Swordfish;
Device = 18F4520 Clock = 8 Config OSC = INTIO67 // Use the Internal Oscillator Include "utils.bas" Dim LED As PORTA.0 // Assign an alias for "LED" // Start Of Program... OSCCON = %01111111 // Sets up the internal oscillator SetAllDigital // Make all Pins digital I/O's Low(LED) // Make the LED pin an output and set it low While True LED = 1 // Turn on the LED DelayMS(500) // Delay for half a second LED = 0 // Turn off the LED DelayMS(500) // Delay for half a second Wend
The wiring diagram is as follows (note your will need 5V to pin 1, 11 and 32. GND to 12, 31);
Therefore R = V/I
Then R = 150 ohms
|
|
| Last Updated ( Sunday, 15 November 2009 01:04 ) |
Whos Online
- andyo
- MrDEB
Forum Activity
LCD / 18F1320 - mrdeb Saturday, 20 March 2010 06:21 - [3 replies]
A 'throw-away" PIC board - mrdeb Thursday, 18 March 2010 06:19 - [32 replies]
Credit Where Credit's Due - jon chandler Tuesday, 16 March 2010 12:01 - [9 replies]
Marching LEDs - mrdeb Saturday, 13 March 2010 22:54 - [7 replies]
USB 8 Channel Servo Controller - andyo Saturday, 13 March 2010 01:19 - [2 replies]
Dedicated Servo Controller - graham Friday, 12 March 2010 17:58 - [0 replies]
Must have....delta temperature glowies! - graham Friday, 12 March 2010 17:31 - [3 replies]




Nice. The TAP-28 boards are looking good. When I've had a buzzi...
The author (Hop) suggests to "set the target PIC's configuratio...
Graham, Thanks for fixing the spacing on the array. This is how i...
Thanks Graham, It is a problem with Flowcode because the demo wa...
Looks like you've pretty much solved every minor issue that was enc...
The low-cost servo does have one other feature. The origina...
I am not familiar with flowcode, though did you try powering the bo...
Hello there, I am still trying to get the LCD to work but I am pro...