#include <Wire.h>
#include "ssd1306.h"
#include <Adafruit_SSD1306.h>
// define output pins for relays
const int clock = 12; // name clock
const int restart = 11; // name restart
const int relay = 10; // Rms relay
const int data = 9; // Slot Enable
const int rest = 8; // slot restart
const int slot_c = 7; // slot C signal to Sub COntroler
const int slot_b = 6; // slot B signal to Sub COntroler
const int slot_a = 5; // slot A signal to Sub COntroler
const int sys = 4; // System Btn
// Default values for Slots
int val = 0;
int sys = 0;
int st = 1;
// image coding & related info
#define screen_width 128
#define screen_height 64
Adafruit_SSD1306 display(screen_width, screen_height);
// '2181328878539831', 128x64px
const unsigned char bitmap[] PROGMEM =
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xdb, 0xee, 0xff, 0xa7, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0xf1, 0xef, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x00, 0x00, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x7f, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x1c, 0x03, 0xfc, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x02, 0x00, 0x03, 0xf1, 0xf0, 0x00, 0x00, 0x00, 0x1f, 0xff,
0xff, 0xff, 0xff, 0x80, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x38, 0x7f, 0x00, 0x00, 0x01, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x07, 0xff, 0x80, 0xff, 0xf8, 0x1f, 0x1f, 0xf8, 0x00, 0x3f, 0xff, 0xff,
0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x01, 0xff, 0xf8, 0x0f, 0x8f, 0xfc, 0x87, 0xff, 0xff, 0xff,
0xff, 0xfc, 0x00, 0x07, 0xff, 0xfe, 0x03, 0xff, 0xfe, 0x07, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xe0, 0x00, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xf8, 0x02, 0x00, 0x17, 0xff, 0xff, 0xff, 0xff,
0xff, 0xc0, 0x07, 0xff, 0xff, 0xbc, 0x0f, 0xc1, 0xe0, 0x03, 0xb0, 0x67, 0xff, 0xff, 0xff, 0xff,
0xff, 0x80, 0x1f, 0xff, 0xf0, 0x3c, 0x0f, 0x00, 0xe0, 0x01, 0x78, 0x0f, 0xfc, 0x3f, 0xff, 0xff,
0xff, 0x00, 0x7f, 0xff, 0xc0, 0x7c, 0x1f, 0xe3, 0xf3, 0xb0, 0x18, 0x03, 0xff, 0x81, 0xff, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xfc, 0x1f, 0xff, 0xf0, 0x00, 0x18, 0x01, 0xff, 0xe0, 0x1f, 0xff,
0xff, 0xc0, 0xff, 0xfc, 0x00, 0xf8, 0x0f, 0xff, 0xb0, 0x01, 0xfc, 0x00, 0x7f, 0xf8, 0x0f, 0xff,
0xff, 0xe0, 0x3f, 0xf0, 0x00, 0xfc, 0x0f, 0xc0, 0xe0, 0x01, 0xf8, 0x00, 0x1f, 0xf8, 0x0f, 0xff,
0xff, 0xfa, 0x0f, 0xc0, 0x01, 0xff, 0xf1, 0x0e, 0x00, 0x02, 0x48, 0x00, 0x0f, 0xf0, 0x07, 0xff,
0xff, 0xff, 0xe5, 0x00, 0x01, 0xff, 0x9c, 0xc0, 0xc0, 0x05, 0xf8, 0x00, 0x01, 0x80, 0x0f, 0xff,
0xc2, 0x3f, 0x80, 0x00, 0x01, 0xc1, 0xc4, 0x46, 0x00, 0x09, 0xf0, 0x00, 0x00, 0x00, 0x3f, 0xff,
0xf0, 0x1c, 0x00, 0x00, 0x01, 0x7c, 0x22, 0x7f, 0xe1, 0xff, 0x80, 0x00, 0x00, 0x40, 0x7f, 0xff,
0xfc, 0x1c, 0x00, 0x00, 0x07, 0xc1, 0x80, 0x02, 0xc3, 0xfc, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff,
0xfe, 0x1c, 0x00, 0x00, 0x07, 0xc2, 0x0e, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff,
0xfe, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x50, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff,
0xfe, 0x18, 0x00, 0x00, 0x00, 0x01, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff,
0xfe, 0x18, 0x00, 0x00, 0x00, 0x01, 0x8f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff,
0xfe, 0x18, 0x7f, 0xe1, 0xc7, 0xe1, 0x8d, 0xe0, 0x80, 0x00, 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fc, 0x18, 0x3f, 0xf8, 0x71, 0xe3, 0x8f, 0xfc, 0x61, 0x0f, 0xfe, 0x22, 0x0f, 0xf9, 0x3f, 0xff,
0xfc, 0x18, 0x1f, 0x40, 0x63, 0xc3, 0x07, 0xe0, 0xc7, 0x87, 0xfc, 0x2e, 0x4f, 0xf9, 0x3f, 0xff,
0xe0, 0x18, 0x00, 0x03, 0xcf, 0x03, 0x00, 0x01, 0x9f, 0x00, 0x00, 0xfe, 0x07, 0xc1, 0x3f, 0xff,
0xcf, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xf0, 0x19, 0x0f, 0xff,
0xa0, 0x24, 0x90, 0x01, 0x00, 0x50, 0x04, 0x01, 0x40, 0x45, 0x53, 0x7d, 0xbf, 0xef, 0xff, 0xff,
0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff,
0x42, 0x00, 0x21, 0x8c, 0x86, 0xc2, 0x09, 0x20, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0d, 0xff,
0x07, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x01, 0xff,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc2, 0xff, 0xfe, 0x04, 0x81, 0xff,
0x00, 0x12, 0x08, 0x00, 0x00, 0x00, 0x20, 0x80, 0x00, 0x20, 0x03, 0x00, 0x02, 0x00, 0x01, 0xff,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xff,
0xc0, 0x80, 0x00, 0x0f, 0x04, 0x18, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xe4, 0x7f, 0xff, 0xce, 0xc3, 0xbd, 0xe6, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xe1, 0xc1, 0x10, 0x48, 0x84, 0x11, 0xe0, 0x3c, 0x22, 0x00, 0x83, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x3a, 0xec, 0xde, 0x11, 0xf2, 0x3e, 0x63, 0x48, 0x9f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 1040)
const int bitmap_logoallArray_LEN = 1;
const unsigned char* bitmap_logoallArray[1]={bitmap};
void blink(int x)
{
for (int i = 0; i <= x; ++i)
{
digitalWrite(clock, HIGH);
delay(250);
digitalWrite(clock, LOW);
delay(250);
}
}
void off()
{
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(5, 10);
display.print("Take Care");
display.display();
delay(1000);
display.clearDisplay();
}
void welcome()
{
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(28, 8);
display.print("WELCOME");
display.display();
delay(1000);
display.setTextSize(3);
display.setCursor(50, 36);
display.print("TO");
display.display();
delay(500);
display.clearDisplay(); // clearing screen
display.drawBitmap
( (display.width() - screen_width ) / 2,
(display.height() - screen_height) / 2,
bitmap, screen_width, screen_height, 1);
display.display();
delay(3000);
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(32, 0);
display.print("DEPARTMENT");
display.display();
delay(500);
display.setTextSize(1);
display.setCursor(55, 10);
display.print("OF");
display.display();
delay(500);
display.setTextSize(1);
display.setCursor(30, 30);
display.print("INFORMATION");
display.display();
delay(500);
display.setTextSize(1);
display.setCursor(33, 40);
display.print("TECHNOLOGY");
display.display();
delay(2000);
display.clearDisplay();
delay(500);
display.setTextSize(2);
display.setCursor(5, 0);
display.print("PRESENTING");
display.display();
delay(500);
display.setTextSize(2);
display.setCursor(45, 20);
display.print("YOU");
display.display();
delay(1000);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(30, 0);
display.print("ENERGY");
display.display();
blink(6);
delay(250);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(20, 20);
display.print("ANALIZER");
display.display();
blink(8);
delay(250);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(30, 40);
display.print("SYSTEM");
display.display();
blink(6);
delay(250);
display.clearDisplay();
display.setTextSize(4);
display.setTextColor(SSD1306_WHITE);
display.setCursor(42, 12);
display.print("BY");
display.display();
delay(1000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("1. AMMAR Ali");
display.display();
delay(1000);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 20);
display.print("2. MAHNOOR KHAN");
display.display();
delay(1000);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 40);
display.print("3. LAVESHA KUMARI");
display.display();
delay(4000);
}
void setup()
{
pinMode (sys, INPUT);
pinMode (ALM, OUTPUT);
pinMode (clock, OUTPUT);
digitalWrite(ALM, HIGH);
digitalWrite(clock, HIGH );
delay(150);
digitalWrite(clock, LOW);
digitalWrite(clock, LOW);
// SCREEN ADDRESSING
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop()
{
sys = digitalRead(2); // read the input pin
if ( st == 1)
{
if ( sys == HIGH )
{
if (val == 0)
{
digitalWrite(ALM, HIGH); // sets the LED to the button's value
val = 1;
st = 1;
welcome();
delay(10);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 20);
display.print("SYSTEM READY");
display.display();
}
else if ( val == 1)
{
digitalWrite(ALM, LOW); // sets the LED to the button's value
val = 0;
off();
delay(10);
st = 0;
}
}
}
}
Rst
C
Clock
Data
B
A
SYS BTN
RMS Relay
Rst
Online
Voltages
Slot C
Slot B
Slot A