write a programing in assimbly language 8086 not 8085 for a
write a programing in assimbly language 8086 not 8085 for a circuit has a humiduty sensor ,and pumb connect with relay 5v ,and source 5 v ,
if humiduty sensor is on the pumb is off , if humiduty sensor is off the pumb is on
Solution
write a program in 8086 has a humidity sensor ,and pumb connect with relay 5v ,and source 5 or,if sensor is on the pump is off , if sensor is off the pump is on
#include <EEPROM.h>
#define inputLevel1 4 //Tank Level-Low
#define inputLevel2 7 //Tank Level-High
#define modeSwitch 2 //Auto/Manual Mode Switch
#define statLED 8 //System Status Indicator
#define modeLED 12 //Auto/Manual Mode Indicator
#define driveOutput 13 //Water Pump Swicth Output
#define memposL1 0 //Set constant eeprom position 0 to save Level1
int state=0;
int level = 0;
int lastlevel = 0;
void setup (){
pinMode(modeSwitch,INPUT);
pinMode(inputLevel1,INPUT);
pinMode(inputLevel2,INPUT);
digitalWrite(modeSwitch, HIGH);
digitalWrite(inputLevel1, HIGH);
digitalWrite(inputLevel2, HIGH);
pinMode(driveOutput, OUTPUT);
pinMode(statLED, OUTPUT);
pinMode(modeLED, OUTPUT);
level = EEPROM.read(memposL1);
lastlevel = level;
if ((level == 0)||(level>2)) {
level=1;
refreshmem();
}
visualdrive();
delay(1000);
pumpdrive();
}
void visualdrive() {
digitalWrite(statLED, LOW );
if (level >1) digitalWrite(statLED, HIGH );
}
void pumpdrive(){
if (level < 2) digitalWrite(driveOutput, HIGH );
if ((level == 2) & (state == 0)) {
digitalWrite(driveOutput, LOW );
}
else {
digitalWrite(driveOutput, HIGH );
}
}
void refreshmem() {
lastlevel = level;
EEPROM.write(memposL1, level);
}
void loop () {
if ( (digitalRead(modeSwitch) == LOW) & (state == 0) ) {
state=1;
digitalWrite(modeLED, state );
pumpdrive();
delay(400);
}
if ( (digitalRead(modeSwitch) == LOW) & (state == 1) ) {
state=0;
digitalWrite(modeLED, state );
pumpdrive();
delay(400);
}
if ( digitalRead(inputLevel1) == LOW ) {
level = 1;
}
if ( digitalRead(inputLevel2) == LOW ) {
level = 2;
}
if (level != lastlevel) {
visualdrive();
pumpdrive();
refreshmen();
}
}

