--> Project I -12. Nurse Call using 7 Segment Display Based on Arduino | basic arduino tutorial

Thursday, August 24, 2017

Project I -12. Nurse Call using 7 Segment Display Based on Arduino

| Thursday, August 24, 2017
Nurse Call using 7 Segment Display


Generally this tools is look Like A nurse caller at the hospital. how the system works as follows, push button botton as trigger alarm on nurse room, button put in every room patient. Seven segment will displays patient room that replaced by number of buttons on board. In the nurse room there is a push on button (pickup button) to turn off the alarm and continue the queue sequence of patients who pressed the button. In this application there are 2 Arduino UNO, 1 Arduino is used to handle the pressed button, the data is sent serially to the other arduino, then the data is displayed on seven segment.

Hardware Requirement
  • 2 Arduino Uno Board
  • 6 Digit of 7-Segment with Common Anode
  • 17 Push Button
  • Buzzer
  • Power supply +5 Volt
  • Jumper


7-Segment | Source                   Push Button | Source


Buzzer | Source

Block Diagram


Schematic

  --> Arduino 1




 -->  Arduino 2


7-Segment CA Wiring | Source



 Arduino 1 - Arduino 2 Wiring



Arduino 1 - Buttons Wiring



Arduino 2 - 7-Segment Wiring


Arduino 2 - Components Wiring


Source Code --> Arduino 1

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
byte in_serial,str;
boolean tb1,tb2,tb3,tb4,tb5,tb6,tb7,tb8,tb9=true;
boolean tb10,tb11,tb12,tb13,tb14,tb15,tb16=true;
String inString="";
char f;
void setup(){
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
pinMode(A4,INPUT);
pinMode(A5,INPUT);
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
delay(100);
mySerial.begin(9600);
tb1=true;
tb2=true;
tb3=true;
tb4=true;
tb5=true;
tb6=true;
tb7=true;
tb8=true;
tb9=true;
tb10=true;
tb11=true;
tb12=true;
tb13=true;
tb14=true;
tb15=true;
tb16=true;
Serial.begin(9600);
}
void loop() {
if(digitalRead(4)==LOW && tb1==true){
mySerial.println("A01B01");
tb1=false;
delay(500);
}
if(digitalRead(5)==LOW && tb2==true){
mySerial.println("A01B02");
tb2=false;
delay(500);
}
if(digitalRead(6)==LOW && tb3==true){
mySerial.println("A01B03");
tb3=false;
delay(500);
}
if(digitalRead(7)==LOW && tb4==true){
mySerial.println("A01B04");
tb4=false;
delay(500);
}
if(digitalRead(8)==LOW && tb5==true){
mySerial.println("A01B05");
tb5=false;
delay(500);
}
if(digitalRead(9)==LOW&& tb6==true){
mySerial.println("A02B01");
tb6=false;
delay(500);
}
if(digitalRead(10)==LOW && tb7==true){
mySerial.println("A02B02");
tb7=false;
delay(500);
}
if(digitalRead(11)==LOW && tb8==true){
mySerial.println("A02B03");
tb8=false;
delay(500);
}
if(digitalRead(12)==LOW && tb9==true){
mySerial.println("A02B04");
tb9=false;
delay(500);
}
if(digitalRead(13)==LOW && tb10==true){
mySerial.println("A02B05");
tb10=false;
delay(500);
}
if(digitalRead(A0)==LOW && tb11==true){
mySerial.println("A03B01");
tb11=false;
delay(500);
}
if(digitalRead(A1)==LOW && tb12==true){
mySerial.println("A03B02");
tb12=false;
delay(500);
}
if(digitalRead(A2)==LOW && tb13==true){
mySerial.println("A03B03");
tb13=false;
delay(500);
}
if(digitalRead(A3)==LOW && tb14==true){
mySerial.println("A03B04");
tb14=false;
delay(500);
}
if(digitalRead(A4)==LOW && tb15==true){
mySerial.println("A03B05");
tb15=false;
delay(500);
}
if(digitalRead(A5)==LOW && tb16==true){
mySerial.println("A03B06");
tb16=false;
delay(500);
}
if(mySerial.available()){
getSerial();
if (inString=="tb1=true") tb1=true;
else if (inString=="tb2=true")tb2=true;
else if (inString=="tb3=true")tb3=true;
else if (inString=="tb4=true")tb4=true;
else if (inString=="tb5=true")tb5=true;
else if (inString=="tb6=true")tb6=true;
else if (inString=="tb7=true")tb7=true;
else if (inString=="tb8=true")tb8=true;
else if (inString=="tb9=true")tb9=true;
else if (inString=="tb10=true")tb10=true;
else if (inString=="tb11=true")tb11=true;
else if (inString=="tb12=true")tb12=true;
else if (inString=="tb13=true")tb13=true;
else if (inString=="tb14=true")tb14=true;
else if (inString=="tb15=true")tb15=true;
else if (inString=="tb16=true")tb16=true;
Serial.println(inString);
}
}
//----------------
void getSerial(){
f=1;
inString="";
while(f){
if(mySerial.available()){
str=mySerial.read();
switch (str){
case '\r': break;
case '\n':f=0; break;
default:inString+=(char)str;
}
}
}
}



Source Code --> Arduino 2


#include <EEPROM.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
byte in_serial,str;
long lastButton = 0;
long delayAntiBouncing = 50;
byte f_data, addr, addr_tampil, pickUp;
byte bacaRuang, bacaKamar, antrian;
byte lanjut, f_tampilan;
byte simpanRuang, simpanKamar;
char f;
int i, j;
String inString="";
String Stemp="";
byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 }, // = 0
{ 1,0,0,1,1,1,1 }, // = 1
{ 0,0,1,0,0,1,0 }, // = 2
{ 0,0,0,0,1,1,0 }, // = 3
{ 1,0,0,1,1,0,0 }, // = 4
{ 0,1,0,0,1,0,0 }, // = 5
{ 0,1,0,0,0,0,0 }, // = 6
{ 0,0,0,1,1,1,1 }, // = 7
{ 0,0,0,0,0,0,0 }, // = 8
{ 0,0,0,0,1,0,0 }, // = 9
};
void setup(){
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
pinMode(12,INPUT);
digitalWrite(12, HIGH);
mySerial.begin(9600);
}
void loop(){
if(mySerial.available()){
getSerial();
i=inString.indexOf('A');
j=i+3;
Stemp=inString.substring((i+1),j);
simpanRuang=Stemp.toInt();
addr++;
EEPROM.write(addr,simpanRuang);
i=inString.indexOf('B');
j=i+3;
Stemp=inString.substring((i+1),j);
simpanKamar=Stemp.toInt();
addr++;
EEPROM.write(addr,simpanKamar);
f_data++;
}
if (f_data > 0){
if(pickUp==0 && f_tampilan==0){
bacaRuang=EEPROM.read(1);
bacaKamar=EEPROM.read(2);
lanjut++;
f_tampilan=1;
}
else if(pickUp==1){
statusTombol();
lanjut++;
addr_tampil = lanjut*2;
bacaKamar=EEPROM.read(addr_tampil);
addr_tampil = addr_tampil-1;
bacaRuang=EEPROM.read(addr_tampil);
pickUp=0;
f_data--;
}
tampil7Segment();
digitalWrite(13, HIGH);
}
else{
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH); digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH); digitalWrite(A5,HIGH);
addr=0;
addr_tampil=0;
f_data=0;
pickUp=0;
lanjut=0;
f_tampilan=0;
digitalWrite(13, LOW);
}
if(digitalRead(12)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if(f_data > 0) {
pickUp=1;
}
}
lastButton = millis();
}
}
void tampil7Segment(){
digitalWrite(A0,LOW); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH); digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH); digitalWrite(A5,HIGH);
sevenSegWrite(bacaRuang / 10);
delay(5);
digitalWrite(A0,HIGH); digitalWrite(A1,LOW);
digitalWrite(A2,HIGH); digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH); digitalWrite(A5,HIGH);
sevenSegWrite(bacaRuang % 10);
delay(5);
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,LOW); digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH); digitalWrite(A5,HIGH);
sevenSegWrite(bacaKamar / 10);
delay(5);
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH); digitalWrite(A3,LOW);
digitalWrite(A4,HIGH); digitalWrite(A5,HIGH);
sevenSegWrite(bacaKamar % 10);
delay(5);
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH); digitalWrite(A3,HIGH);
digitalWrite(A4,LOW); digitalWrite(A5,HIGH);
sevenSegWrite(f_data / 10);
delay(5);
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH); digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH); digitalWrite(A5,LOW);
sevenSegWrite(f_data % 10);
delay(5);
}
void sevenSegWrite(byte segment){
byte pin = 4;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}
void statusTombol(){
if (bacaRuang==1 && bacaKamar==1){
mySerial.println("tb1=true");
}
else if (bacaRuang==1 && bacaKamar==2){
mySerial.println("tb2=true");
}
else if (bacaRuang==1 && bacaKamar==3){
mySerial.println("tb3=true");
}
else if (bacaRuang==1 && bacaKamar==4){
mySerial.println("tb4=true");
}
else if (bacaRuang==1 && bacaKamar==5){
mySerial.println("tb5=true");
}
else if (bacaRuang==2 && bacaKamar==1){
mySerial.println("tb6=true");
}
else if (bacaRuang==2 && bacaKamar==2){
mySerial.println("tb7=true");
}
else if (bacaRuang==2 && bacaKamar==3){
mySerial.println("tb8=true");
}
else if (bacaRuang==2 && bacaKamar==4){
mySerial.println("tb9=true");
}
else if (bacaRuang==2 && bacaKamar==5){
mySerial.println("tb10=true");
}
else if (bacaRuang==3 && bacaKamar==1){
mySerial.println("tb11=true");
}
else if (bacaRuang==3 && bacaKamar==2){
mySerial.println("tb12=true");
}
else if (bacaRuang==3 && bacaKamar==3){
mySerial.println("tb13=true");
}
else if (bacaRuang==3 && bacaKamar==4){
mySerial.println("tb14=true");
}
else if (bacaRuang==3 && bacaKamar==5){
mySerial.println("tb15=true");
}
else if (bacaRuang==3 && bacaKamar==6){
mySerial.println("tb16=true");
}
}
void getSerial(){
f=1;
inString="";
while(f){
if(mySerial.available()){
str=mySerial.read();
switch (str){
case '\r': break;
case '\n':f=0; break;
default:inString+=(char)str;
}
}
}
}

How it Works

1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.

3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. The first display on the seven segment



5. When one of the button is pressed it will looks like this below

6. While there is still a queue, the Arduino 2 or the receiver operator will ring the buzzer Until the push button is 
    pressed.


Video for Project I -12. Nurse Call using 7 Segment Display Based on Arduino




Required file

Related Posts

5 comments: