ApacheOmega
Programmer
- Dec 6, 2012
- 1
- 0
- 0
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///////////////////
is this part right so far?????????????????
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