EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Bascom Code to c conversion

Bascom Code to c conversion

|

Microcontroller › 8051 › Bascom Code to c conversion

  • This topic has 0 replies, 1 voice, and was last updated 12 years, 7 months ago by Yadwinder Mehal.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • May 4, 2013 at 3:56 pm #2369
    Yadwinder Mehal
    Participant

    hello friends is there any one who can help me to convert this  Bascom Code  to c code for keil.

     

    '  SMS Device controller
    $regfile = "89S8252.dat"
    $large
    Config Lcd = 16 * 2
    'define xtal speed
    $baud = 9600
    $crystal = 11059200


    'declare constants
    Declare Sub Getline
    Declare Sub Send_sms


    'LCD connections
    Config Lcdpin = Pin , Db4 = P0.2 , Db5 = P0.3 , Db6 = P0.4 , Db7 = P0.5 , E = P0.1 , Rs = P0.0


    Load1 Alias P2.7
    Load2 Alias P2.6
    Load3 Alias P2.5
    Load4 Alias P2.4




    Dim Temp As Byte
    Dim Gps As Byte
    Dim Sty As String * 1
    Dim Adres As Byte
    Dim Value As Byte
    Dim Num As String * 10
    Dim Disp As String * 16
    Dim Inmsg As String * 100


    P2 = 255 'switch off all loads
    Cursor Off
    Cls
    Lcd "Initializing"
    Lowerline
    Lcd "Modem plz wait.."


    Wait 10 ' give some time for gsm modem


    Print "AT"
    Wait 2
    Print "ATE0" 'Echo off
    Wait 2
    Print "AT+CREG?"
    Wait 2
    Print "AT+CNMI=2,0,2,0,0" 'new message indication off
    Wait 2
    Print "AT+CMGF=1" 'change to Text mode
    Wait 2
    Print "AT+CMGD=1,4" 'Delete all sms
    Wait 2

    Cls
    Lcd "Waiting for SMS."

    Do
    Print "AT+CMGR=1" 'Read for message
    Getline
    If Inmsg <> "OK" Then 'got new message
    Num = ","
    Gps = Instr(inmsg , Num)
    Gps = Gps + 5
    Num = Mid(inmsg , Gps , 10) 'extract the sender number
    Getline 'get the message
    Inmsg = Lcase(inmsg)


    Cls
    Lcd "1 Msg Received"
    Lowerline
    Lcd "from:" ; Num
    Wait 1


    If Inmsg = "load1 on" Then
    Reset Load1
    Inmsg = "Load1 Switch ON"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load1 off" Then
    Set Load1
    Inmsg = "Load1 Switch OFF"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load2 on" Then
    Reset Load2
    Inmsg = "Load2 Switch ON"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load2 off" Then
    Set Load2
    Inmsg = "Load2 Switch OFF"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load3 on" Then
    Reset Load3
    Inmsg = "Load3 Switch ON"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load3 off" Then
    Set Load3
    Inmsg = "Load3 Switch OFF"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load4 on" Then
    Reset Load4
    Inmsg = "Load4 Switch ON"
    Cls
    Lcd Inmsg
    Send_sms
    Elseif Inmsg = "load4 off" Then
    Set Load4
    Inmsg = "Load4 Switch OFF"
    Cls
    Lcd Inmsg
    Send_sms
    End If
    Wait 1
    Print "AT+CMGD=1,4" 'delete all sms
    Wait 1


    Cls
    Lcd "Waiting for SMS."
    End If
    Wait 2
    Loop
    End
    'continious loop


    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    ' SEND SMS
    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Sub Send_sms
    If Num <> "" Then
    Wait 3
    Print "AT+CMGS=" ; Chr(34) ; "+91" ; Num ; Chr(34) 'send sms
    Waitms 200
    Print Inmsg ; Chr(26)
    Wait 5
    End If
    End Sub


    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    ' Read gsm modem
    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Sub Getline
    Inmsg = ""
    Do
    Gps = Inkey()
    If Gps > 0 Then
    Select Case Gps
    Case 13 : If Inmsg <> "" Then Exit Do ' if we have received something
    Case 10 : If Inmsg <> "" Then Exit Do ' if we have received something
    Case Else
    Inmsg = Inmsg + Chr(gps) ' build string
    End Select
    End If
    Loop


    End Sub
    '//////////

     

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • 1.1kV Cockroft-Walton 200J Capacitor Charger December 4, 2025
  • Samba ( not the dance) December 4, 2025
  • mechanism to shutdown feeding when sensor temperature rises December 4, 2025
  • Looking for a ~1″ Analog CVBS Micro-Display — Any Sources? December 4, 2025
  • Annex32 Basic for ESP Micros December 4, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise