CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2012
    Posts
    18

    trying to write a program that takes input from Sensor and outputs to LED

    In assembly language how do I write code to take input from a sensor and turns on a LED?
    I'm writing an assembly program that will read information from a sensor that will detect whether its raining or not. the sensor will be the input and the LED will be the output indicating that its raining.
    I have code written for 5 other weather conditions but right now I just want to figure out the most basic which is rain.

    here's my code///////////////////////////I just want to know if I'm headed in the right direction, If not do you have any suggestions///////////////////
    Code:
    #include <p16F690.inc>
    ;----------------------------
    ;define equates here
    ;----------------------------
    count equ 0x00
    sum equ 0x09
    
    rainLed equ 4
    rainSensor 10
    
    dayOrNightLed equ 3
    dayOrNightSensor 9
    
    windLed equ 2
    windSensor 8
    
    snowLed equ 1
    snowSensor 7
    
    tempLed equ 0
    tempSensor 6
    
    fogLed equ 0
    foqSensor 5
    
    ;---------------------------
    ;start of program
    ;---------------------------
    
    org 0x0000 ; tells program to start at first location
    start:
    
    BSF status, RP0 ; select bank 1
    BCF status RP1
    
    movlw b'11111000' ; make bank 5-10 inputs
    movwf TRISA ;make bank 4-0 output
    
    BCF status RP0 ;bit clear file
    BCF status RP1
    
    ;------------------------------
    ;Loop
    ;-----------------------------
    BTFSS PortA, rainSensor
    BSF PortA,rainLed
    is this part right so far?????????????????

  2. #2
    Join Date
    Dec 2012
    Location
    WA
    Posts
    4

    Re: trying to write a program that takes input from Sensor and outputs to LED

    initialize your thing--- system, dos or asm. BASIC is a program
    define your variables-
    address your starting, ending and offset.-
    build your exe-

  3. #3
    Join Date
    Dec 2012
    Location
    WA
    Posts
    4

    Re: trying to write a program that takes input from Sensor and outputs to LED

    [SYSTEM]
    for sensors(1 to n)
    next n
    if sensors(n) > 1
    then trigger.system.led1 ; lights led1
    else sensors(n) = 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured