![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Experienced Member
|
i am working on a simple program to just test displaying data on the lcd, while processing the input from buttons, I finshed code i think will work, i just wana see if any one see some potential hangups, the code is written in basic
thanks for the help |
|
|
|
|
|
(permalink) |
|
Experienced Member
|
this looks like swordfish and if so i dont think you need to have the word SUB in there:
Code:
While True
If Switch = 1 Then Sub LED1
EndIf
If Switch2 = 1 Then Sub LED2
EndIf
Wend
Code:
Device = 18F2550
Clock = 20
// some LCD options...
#option LCD_DATA = PORTB.4 // Assign the LCD connections
#option LCD_EN = PORTB.3 //
#option LCD_RS = PORTB.2 //
// import LCD library...
Include "LCD.bas"
Include "utils.bas"
Include "convert.bas"
Dim Var1 As Word
Dim LED As PORTA.0 // Assign an alias for "LED"
Dim LED2 As PORTA.1 // Assign an alias for "LED2"
Dim Switch As PORTA.2, // Assign an alias for "Switch"
Dim Switch2 As PORTA.3, // Assign an alias for "Switch2"
//subs
Sub Debounce()
DelayMS(10) // Small delay to stop "bouncing"
While Switch = 1 // Wait for the switch to be de-pressed
Wend //
End Sub
Sub LEDA()
LED = 1
DelayMS 100
LED = 0
DelayMS 100
End Sub
Sub LEDB()
LED2 = 1
DelayMS 100
LED2 = 0
DelayMS 100
End Sub
// Start Of Program...
SetAllDigital // Make all pins digital I/O's
Input(Switch) // Make the switch pin an input
Low(LED) // Make the LED an output and set it Low
Input(Switch2) // Make the switch1 pin an input
Low(LED2) // Make the LED2 an output and set it Low
DelayMS(150) // Let the LCD warm up
Cls // Clear the LCD screen
WriteAt(1,1,"test") // Send some text to the LCD
DelayMS(1000)
WriteAt(2,1,"test")
DelayMS(1000)
WriteAt(3,1,"Input function test")
DelayMS(1000)
WriteAt(4,1."2 input, 2 output")
While True
If Switch = 1 Then LEDA
EndIf
If Switch2 = 1 Then LEDB
EndIf
Wend
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Whitfield Pellet Stove Problems | Sheriffjer | General Electronics Chat | 6 | 1st November 2007 01:36 PM |
| USB to Serial problems | spondootre | Micro Controllers | 12 | 28th November 2006 08:09 AM |
| Surge problems | leonel | Electronic Projects Design/Ideas/Reviews | 3 | 15th September 2006 02:36 PM |
| 3.2V to 5V TTL interface problems | GraveYard_Killer | Micro Controllers | 9 | 12th March 2005 01:29 PM |
| Potential divider... | Appleon | Electronic Projects Design/Ideas/Reviews | 10 | 24th May 2004 09:45 PM |