#include <LiquidCrystal.h>
#include <string.h>
const int rs =12,en=11,d4=5,d5=4,d6=3,d7=2;
int A,B,C,D,E,H,L = 0x0;
//int S,Z,AC,Carry
int flags[4] = {0,0,0,0};
//memory array
int memory[60] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
//push button,execute,enter
int pushButton = 18;
int execute = 19;
volatile boolean character_changed = false;
//int enter = ;
///////////////////////////
int executeState = 0;
int enterState = 0;
//always high pin
int alwayshigh = 34;
boolean high_led = false;
//The array of states
int state = 1; //this is needed to take input from user using the push button
int states[2] = {0,1};//1=Write,0=Read
//the array for characters to take input
char instructionChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,";
char currentCharacter = 'A';
/////////////////////////////////////////////////////
int currentCursor[] = {0,0};
void setup() {
// put your setup code here, to run once:
pinMode(pushButton,INPUT_PULLUP);
pinMode(execute,INPUT);
// pinMode(enter,INPUT);
pinMode(50,OUTPUT);
pinMode(alwayshigh,OUTPUT);
digitalWrite(alwayshigh,HIGH);
lcd.begin(16,2);
lcd.print("8085 Simulator");
delay(2000);
lcd.clear();
lcd.setCursor(6,0);
attachInterrupt(digitalPinToInterrupt(pushButton), changecharacter, RISING);
for(int i =0;i<=3;i++){
lcd.print(flags[i]);
}
lcd.setCursor(16,1);
currentCursor[0] = 16;
lcd.setCursor(0,1);
lcd.print("Char No ");
lcd.setCursor(8,1);
lcd.print("0");
lcd.setCursor(10,1);
lcd.print(currentCharacter);
}
//The ISR of the pushbutton
void changecharacter()
{
character_changed=true;
}
///////////////////////////////
//The ISR of the the execute
// void executefunction(){
// delay(100);
// }
//////////////////////////////////
//The ISR of enter
// void enter(){
// }
int blinkingCharacter(char character,int x,int y){
while(enterState == 0){
lcd.setCursor(x,y);
lcd.print(character);
delay(100);
lcd.print(" ");
}
}
void loop() {
// put your main code here, to run repeatedly:
if (character_changed)
{
high_led=!high_led;
digitalWrite(50,high_led);
for(int i=0;i<=36;i++)
{
if (instructionChars[i] == currentCharacter)
{
if (i > 36) i=0;
lcd.setCursor(0,1);
lcd.print("Char No ");
lcd.setCursor(8,1);
lcd.print(i);
lcd.setCursor(10,1);
currentCharacter = instructionChars[i+1];
lcd.print(currentCharacter);
break;
}
}
character_changed=false;
currentCursor[0] -= 1;
}
}