Program 1:
#include <Servo.h>
Servo mitral;
Servo tricuspid;
Servo pulmonic;
Servo aortic;
int menu;
int exit1;
int tachy;
void setup()
{
Serial.begin(9600);
mitral.attach(11);
tricuspid.attach(10);
pulmonic.attach(5);
aortic.attach(9);
pinMode(2, OUTPUT); //SA
pinMode(3, OUTPUT); //AV
pinMode(4, OUTPUT); //His bundle
pinMode(7, OUTPUT); //Right network
pinMode(6, OUTPUT); //Left network
pinMode(A1, INPUT); //Menu
pinMode(A5, INPUT); //Exit
pinMode(12,INPUT);
}
void loop()
{
menu = analogRead(A1);
exit1 = analogRead(A5);
tachy = digitalRead(12);
//Serial.println(tachy);
//Serial.println(exit1);
//Serial.println(menu);
if (exit1 == 0)
{
Serial.println("Switch OFF");
delay(1000);
}
else if (exit != 0)
{
if (menu >= 660) //Normal function
{
//Serial.println("Normal Sinus");
normal();
}
else if (menu <= 600 and menu >= 480) // Junctional
{
//Serial.println("Junctional");
junctional();
}
else if (menu <= 460 and menu >= 420) // V_rhythm
{
//Serial.println("Ventricular rhythm");
v_rhythm();
}
else if (menu <= 350 and menu >= 310) //Pulseless
{
PEA();
}
else if (menu <= 260 and menu >= 170) //I degree
{
Frst_deg();
}
else if (menu <= 140 and menu >= 60) //II Degree
{
Sec_deg();
}
else if (menu <= 50 and menu >= 0) //III Degree
{
CHB();
}
}
}
int normal()
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, HIGH);
delay(300);
digitalWrite(2,LOW);
digitalWrite(3, HIGH);
mitral.write(90);tricuspid.write(90);
delay(1000);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
if (tachy == LOW)
{
delay(2000);
}
else
{
delay(200);
}
}
int junctional()
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2,LOW);
digitalWrite(3, HIGH);
mitral.write(90);tricuspid.write(90);
delay(1500);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(700);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
if (tachy == LOW)
{
delay(2500);
}
else
{
delay(50);
}
}
int v_rhythm()
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2,LOW);
digitalWrite(3, LOW);
mitral.write(90);tricuspid.write(90);
delay(300);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(400);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(300);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
if (tachy == LOW)
{
delay(3000);
}
else
{
delay(10);
}
}
int PEA()
{
if (tachy == LOW)
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, HIGH);
delay(300);
digitalWrite(2,LOW);
digitalWrite(3, HIGH);
mitral.write(0);tricuspid.write(0);
delay(1000);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(2500);
}
else if (tachy == HIGH)
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
mitral.write(0);tricuspid.write(0);
//delay(500);
digitalWrite(3, LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(00);
aortic.write(0);
delay(200);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(300);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(10);
}
}
int Frst_deg()
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, HIGH);
delay(700);
digitalWrite(2,LOW);
delay(1500);
digitalWrite(3, HIGH);
mitral.write(90);tricuspid.write(90);
delay(1000);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay (2000);
}
int Sec_deg()
{
if (tachy == LOW) //Type 2
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, HIGH);
delay(400);
digitalWrite(2,LOW);
delay(500);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(3, LOW);
delay(1000)
digitalWrite(2, HIGH);
delay(400);
digitalWrite(2,LOW);
delay(500);
digitalWrite(3, HIGH);
mitral.write(90);tricuspid.write(90);
delay(1000);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay (3000);
}
else if (tachy == HIGH) //Type 1
{
int r = random(100,3000);
Serial.println(r);
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, HIGH);
delay(400);
digitalWrite(2,LOW);
delay(500);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(3, LOW);
delay(r);
digitalWrite(2, HIGH);
delay(700);
digitalWrite(2,LOW);
delay(1500);
digitalWrite(3, HIGH);
delay(300);
mitral.write(90);tricuspid.write(90);
delay(1000);
digitalWrite(3,LOW);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay (2000);
}
}
int CHB()
{
int r = random(100,3000);
Serial.println(r);
mitral.write(0);
tricuspid.write(0);pulmonic.write(0);
aortic.write(0);
digitalWrite(2, HIGH);
delay(800);
digitalWrite(2,LOW);
delay(700);
delay(r);
if (r>2000)
{
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(200);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
digitalWrite(3, HIGH);
delay(700);
digitalWrite(3, LOW);
delay(r);
if (r > 0 and r < 1000)
{
digitalWrite(2, HIGH);
delay(400);
digitalWrite(2,LOW);
delay(r);
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
digitalWrite(2, HIGH);
delay(700);
digitalWrite(2,LOW);
delay(1500);
digitalWrite(3, HIGH);
delay(300);
mitral.write(90);tricuspid.write(90);
delay(1000);
digitalWrite(3,LOW);
if (r > 2000)
{
digitalWrite(2,HIGH);
delay(400);
digitalWrite(2,LOW);
delay(r);
}
mitral.write(0);
tricuspid.write(0);pulmonic.write(90);
aortic.write(90);
if (r > 1000 and r < 2000)
{
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
delay(600);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
pulmonic.write(0);aortic.write(0);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay (3000);
}
Program 2:
#include <LiquidCrystal.h>
LiquidCrystal lcd_1(12, 11, 5, 4, 3, 2);
int menu;
int tachy;
byte customChar_[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b00000
};
byte customChar_P[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00100,
0b01110,
0b11111,
0b00000
};
byte customChar_qRS[8] = {
0b00100,
0b01100,
0b01100,
0b01100,
0b01100,
0b01100,
0b01011,
0b10000
};
byte customChar_T1[8] = {
0b00000,
0b00000,
0b00001,
0b00011,
0b00111,
0b01111,
0b11111,
0b00000
};
byte customChar_T2[8] = {
0b00000,
0b00000,
0b00000,
0b11000,
0b11100,
0b11110,
0b11111,
0b00000
};
byte customChar_WqRS[8] = {
0b00100,
0b01010,
0b11011,
0b11011,
0b11011,
0b11011,
0b11011,
0b00000
};
int asystole()
{
lcd_1.setCursor(1,1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int normal()
{
lcd_1.setCursor(6,1);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int Junctional()
{
lcd_1.setCursor(6,1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int ventricle()
{
lcd_1.setCursor(6,1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)5);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int v_tach()
{
lcd_1.setCursor(8,1);
lcd_1.write((byte)0);
lcd_1.write((byte)5);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
}
int frst_deg()
{
lcd_1.setCursor(6,1);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int sec_ty1()
{
lcd_1.setCursor(1,1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int sec_ty2()
{
lcd_1.setCursor(1,1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
}
int CHB()
{
lcd_1.setCursor(1,1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)2);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)5);
lcd_1.write((byte)0);
lcd_1.write((byte)3);
lcd_1.write((byte)4);
lcd_1.write((byte)1);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)0);
lcd_1.write((byte)1);
}
void setup()
{
pinMode(7,INPUT);
pinMode(A0,INPUT);
pinMode(8,INPUT);
Serial.begin(9600);
lcd_1.begin(16, 2); // Set up the number of columns and rows on the LCD.
lcd_1.createChar(0, customChar_);
lcd_1.createChar(1, customChar_P);
lcd_1.createChar(2, customChar_qRS);
lcd_1.createChar(3, customChar_T1);
lcd_1.createChar(4, customChar_T2);
lcd_1.createChar(5, customChar_WqRS);
}
void loop()
{
tachy = digitalRead(8);
lcd_1.setCursor(0, 0);
if (digitalRead(7) == LOW)
{
lcd_1.clear();
lcd_1.print("Switch OFF!");
asystole();
delay(1000);
}
else if (digitalRead(7) == HIGH)
{
menu = analogRead(A0);
if (menu >= 660) //Normal function
{
lcd_1.clear();
lcd_1.print("Normal Sinus");
normal();
if(tachy == HIGH)
{
lcd_1.setCursor(0, 1);
lcd_1.print("Tachy");
delay(1000);
}
delay(1000);
}
else if (menu <= 600 and menu >= 480) // Junctional
{
lcd_1.clear();
lcd_1.print("Junctional");
Junctional();
if(tachy == HIGH)
{
lcd_1.setCursor(0, 1);
lcd_1.print("Tachy");
delay(1000);
}
delay(1000);
}
else if (menu <= 460 and menu >= 420) // V_rhythm
{
lcd_1.clear();
lcd_1.print("Ventr. Rhythm ");
ventricle();
if(tachy == HIGH)
{
lcd_1.setCursor(0, 1);
lcd_1.print("Tachy");
v_tach();
delay(1000);
}
delay(1000);
}
else if (menu <= 350 and menu >= 310)
{
lcd_1.clear();
lcd_1.print("Pulseless Rhythm");
lcd_1.setCursor(0, 1);
if (tachy == LOW)
{
lcd_1.print("Sinus");
normal();
}
else if (tachy == HIGH)
{
lcd_1.setCursor(0, 1);
lcd_1.print("V-Tach");
v_tach();
delay(1000);
}
delay(1000);
}
else if (menu <= 260 and menu >= 170)
{
lcd_1.clear();
lcd_1.print("First Degree HB");
frst_deg();
delay(1000);
}
else if (menu <= 150 and menu >= 60)
{
lcd_1.clear();
if (tachy == HIGH)
{
lcd_1.print("Second Degree HB Type-1");
sec_ty1();
for(int P = 0; P < 50; P++)
{
lcd_1.scrollDisplayLeft();
delay(150);
}
delay(1000);
}
else
{
lcd_1.print("Second Degree HB Type-2");
sec_ty2();
for(int P = 0; P < 50; P++)
{
lcd_1.scrollDisplayLeft();
delay(300);
}
delay(1000);
}
delay(1000);
}
else if (menu <= 50 and menu >= 0)
{
lcd_1.clear();
lcd_1.print("Complete HB");
CHB();
for(int P = 0; P < 50; P++)
{
lcd_1.scrollDisplayLeft();
delay(150);
}
delay(1000);
}
}
}
Comments