Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

potential problems

Status
Not open for further replies.

joshua17ss2

New 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
 

Attachments

  • lcd1.txt
    1.8 KB · Views: 127
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 [B]Sub[/B] LED1
    EndIf
    If Switch2 = 1 Then [B]Sub[/B] LED2 
    EndIf         
Wend

Also it would be wise to rename the subs since you use LED as a sub and variable you might have issues...

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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top