Instructables

Mini Arduino Multi Function Controller w/ LCD Display

Picture of Mini Arduino Multi Function Controller w/ LCD Display
WP_20131114_010.jpg
WP_20131114_014.jpg
WP_20131114_013.jpg
WP_20131119_013.jpg
This Instructable builds on the mini Arduino environment monitor and mini Arduino EEG monitor Instructables.
It allows you to control  up to 4 relays using time, temperature and /or Light,  your mind, or whatever sensor you would like to use.

The examples are prototypes, I don't go any further than putting them together on a breadboard. I haven't made a permanent case for them

The main purpose of this instructable is to demonstrate how you can use the arduino to control any device using sensor input  and conditional logic to make decisions and activate the device.

My objectives are to make these instructables inexpensive, simple, practical, and interesting.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts and components

Picture of Parts and components
WP_20131113_005.jpg
WP_20131113_003.jpg
I used the same parts for all projects, but if you want to build them for permanent use,you will need to increase the parts count.

For the Timer control:


1. Arduino, I think anyone will do, but I'm using a Sainsmart nano clone.
2. A RTC module for Arduino
3. A Sainsmart 4 Relay module 
4  A Sainsmart 1.8" LCD Color display
5. Jumper wires
6. A mini breadboard to hold the display and/or a larger breadboard for the nano and RTC (I used my RS electronic learning lab)

For the Brain Controller:
  1. An Arduino
  2. A Sainsmart 4 Relay module
  3. A Sainsmart 1.8" LCD Color display
  4. A hacked MindfLEX headset
For light and temperature control:
  1. An Arduino
  2. A Sainsmart 4 Relay module
  3. A Sainsmart 1.8" LCD Color display
  4. A DHT11 or similar temperature sensor, or a thermistor
  5. a CDS light sensor

Step 2: Timer controlled Relays

Picture of Timer controlled Relays
So Let's start with the Timer controller:

This example allows you to control the relays with data provided by the RTC. you can use the date and time data to turn on and/or off the relays.

There are many instructables that show  you how to do just that, but this one provides you feedback status using the color LCD display.

You will need to have the Mini Arduino Enviroment monitor with RTC built to start this project. We will add the 4  Relay module.

Hi

ewry tme when I trie to compile the code I got a massage

sketch_jul27a.ino:33:38: error: #include expects "FILENAME" or <FILENAME>
sketch_jul27a.ino:34:38: error: #include expects "FILENAME" or <FILENAME>
sketch_jul27a.ino:35:35: error: #include expects "FILENAME" or <FILENAME>
sketch_jul27a.ino:36:35: error: #include expects "FILENAME" or <FILENAME>

Help?

this is how code look

#include <Adafruit_GFX.h>

#include <Wire.h>

#include <Adafruit_ST7735.h>

// Sketch Build 1.04 compiled on Arduino 1.0.3.
// This sketch uses the RTC to control 4 relays at whatever cycle or time interval you wish.
// copy the sketch below and paste it into the Arduino IDE verify, and run the program.
// this sketch was created using code from the adafruit and RTC -libraries

//RTC CONNECTIONS
//Connect the RTC VCC to the Arduino +5 v
// RTC GND to the Arduino GND
// RTC SDA to the Arduino Analog Pin 4
// RTC SCL to the Arduino Analog Pin 5

// LCD DISPLAY CONNECTION
#define sclk 4 //connected to digital PIN 4
#define mosi 5 //connected to digital PIN 5
#define cs 6 //connected to digital PIN 6
#define dc 7 //connected to digital PIN 7
#define rst 8 //connected to digital PIN 8

// RELAY CONNECTION
// GND connected to Arduino GND
int Pin1 = 9; // IN1 connected to digital 9
int Pin2 = 10; // IN2 connected to digital 10
int Pin3 = 11; // IN3 connected to digital 11
int Pin4 = 12; // IN4 connected to digital 12
// VCC connected to Arduino +5v

#include // Core graphics library
#include // Hardware-specific library
#include // library needed for RTC
#include // library needed for RTC
#include "RTClib.h" //RTC Library

RTC_DS1307 RTC;

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

void setup(void) {
// DEFINING PINS FOR RELAY CONTROL
pinMode(Pin1, OUTPUT);
pinMode(Pin2, OUTPUT);
pinMode(Pin3, OUTPUT);
pinMode(Pin4, OUTPUT);
Wire.begin();
RTC.begin();

tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab

tft.fillScreen(ST7735_BLACK); // Clear screen
digitalWrite(Pin1, 1 );
digitalWrite(Pin2, 1 );
digitalWrite(Pin3, 1 );
digitalWrite(Pin4, 1 );
tft.setCursor(0,50);
tft.println(" Waiting 10 seconds ");
tft.println(" for RTC to Sync ");
delay(10000);//wait for RTC to Respond, if not set time
tft.fillScreen(ST7735_BLACK); // Clear screen
if (! RTC.isrunning()) {
tft.println(" RTC was NOT running!");
tft.println(" Resetting RTC ");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));

tft.fillScreen(ST7735_BLACK); // Clear screen

}
}

void loop() {
tft.setCursor(10,10);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.println("TIMER CONTROL");

tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);//set text color & size for DATE coming from TinyRTC
tft.setTextSize(2);
tft.setCursor(5,30);
DateTime now = RTC.now(); //GRAB DATE AND TIME FROM RTC
tft.print(now.year(), DEC);
tft.print('/');
tft.print(now.month(), DEC);
tft.print('/');
tft.print(now.day(), DEC);
tft.println(' ');
tft.setCursor(15,70);
tft.setTextColor(ST7735_GREEN,ST7735_BLACK); //set color for TIME
tft.setTextSize(2);//set text size for TIME coming from TinyRTC
tft.print(now.hour(), DEC);
tft.print(':');
if(now.minute() < 10) { //PRINT A 0 IN FRONT OF THE MINUTE IF LESS THAN 10
tft.print('0');
tft.print(now.minute(), DEC);
}
else {
tft.print(now.minute(), DEC);
}
tft.print(':');
if(now.second() < 10) {//PRINT A 0 IN FRONT OF THE SECONDS IF LESS THAN 10
tft.print('0');
tft.print(now.second(), DEC);
}
else {
tft.print(now.second(), DEC);
}
tft.println(" ");
// THIS IS THE DECISION MAKING PORTION OF THE SKETCH, THIS EXAMPLE IS A ONE MINUTE CYCLE
// FOR DEMO PURPOSES: IT TURNS ON RELAY 1 AT 10 SECONDS, THEN OFF AT 20
// IT THEN TURNS RELAY 2 AND 4 ON AT 40 SECONDS AND OFF AT 50,
// AT 50 SECONDS IT TURNS ON RELAY 1 AND 3 THEN OFF AT 0
if(now.second() == 10) {
tft.setCursor(0,100);
tft.setTextColor(ST7735_GREEN,ST7735_BLACK); //set color for TIME ON
tft.setTextSize(1);//set text size
tft.print("Relay 1 is on ");
digitalWrite(Pin1, 0);
}
if(now.second()== 20) {
tft.setCursor(0,100);
tft.setTextColor(ST7735_RED,ST7735_BLACK); //set color for TIME ON
tft.setTextSize(1);//set text size
tft.print("Relay 1 is off ");
digitalWrite(Pin1, 1);
}

if(now.second()== 40){
digitalWrite(Pin1, LOW);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, LOW);
digitalWrite(Pin4, HIGH);
tft.setCursor(0,100);
tft.setTextColor(ST7735_RED,ST7735_BLACK); //set color for TIME ON
tft.setTextSize(1);//set text size
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
tft.println("Relay 1 is on ");
tft.setTextColor(ST7735_RED,ST7735_BLACK);
tft.println("Relay 2 is off ");
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
tft.println("Relay 3 is on ");
tft.setTextColor(ST7735_RED,ST7735_BLACK);
tft.println("Relay 4 is off ");

}
if(now.second()== 50){
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, LOW);
digitalWrite(Pin3, HIGH);
digitalWrite(Pin4, LOW);
tft.setCursor(0,100);
tft.setTextColor(ST7735_RED,ST7735_BLACK); //set color for TIME ON
tft.setTextSize(1);//set text size
tft.println("Relay 1 is off ");
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
tft.println("Relay 2 is on ");
tft.setTextColor(ST7735_RED,ST7735_BLACK);
tft.println("Relay 3 is off ");
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
tft.println("Relay 4 is on ");
}
if(now.second()== 00){
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, HIGH);
digitalWrite(Pin4, HIGH);
tft.setCursor(0,100);
tft.setTextColor(ST7735_RED,ST7735_BLACK); //set color for TIME ON
tft.setTextSize(1);//set text size
tft.println("Relay 1 is off ");
tft.println("Relay 2 is off ");
tft.println("Relay 3 is off ");
tft.println("Relay 4 is off ");
}

}