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///////////////////

#include <>
;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

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

BTFSS PortA, rainSensor
BSF PortA,rainLed

is this part right so far?????????????????

Jason, I suspect that the reason that you have not gotten more responses is simply that you did not specify sufficient background for the problem. I have inferred from the code listing that you are writing code for a microcontroller (apparently the PIC16F690). These always have their own, sometimes rather peculiar assembly formats, and will undoubtedly limit the number of people who will be able to really help. I assume that the controller data sheet specifies a default boot time starting address of 0000, which is where you have indicated your program starts. This should be fine, unless there is a need to write a lot of additional initialization code beyound what you already have for setting up the personality of the I/O ports. The data sheet and extant code examples will be your only real help here. The same is true for the exact techniques needed to read and write I/O registers.

Once you figure out how to address the I/O port that the LED is connected to (which I assume you already know, since you indicated that you have programs for other functions), then turning another LED on should be trivial. What is not clear is the Rain sensor. Since you say nothing about the nature of the sensor, it is really almost impossible to make any suggestions. Is it a simple conductivity threshhold sensor: on when wet, off when dry? Or is it something more complex - like an optical scattering measurement, a rain gauge, etc., that has an analog output and is therefore connected to an A/D converter? If it's a simple switch, then wire it to a digital input and read the respective bit. If it's analog, and the PIC has an A/D converter, then hook it up to that and grab a usage example from the data sheet.

I wish I could be more help, but the PIC series is not my area. Just remember, the data sheet is your best friend. Sometimes very hard to read, but with enough study, virtually everything you need is in there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.