Project tutorial
iShield Console Chat

iShield Console Chat

Send and receive messages (via bluetooth) between Arduino and an iOS device using iShield + BLE Shield + Arduino + TFT LCD Screen.

  • 1,744 views
  • 2 comments
  • 11 respects

Components and supplies

Apps and online services

About this project

In this project we are going to create a chat between an Arduino Uno and an iPhone using the iShield App. The project uses Bluetooth for the communication (Arduino - iPhone), so we are going to use a BLE Shield from Red Bear Labs.

The Arduino is going to send messages to the iOS device when a button is pressed or released. Also, the iOS device is going to be capable to send messages (Strings) to the Arduino using a Console virtual shield, and this messages are going to be displayed in a TFT LCD Screen.

This project uses a TFT LCD Screen from Adafruit, the display uses SPI communication with the Arduino, but the BLE Shield also uses SPI communication and we can not use the same interface at the same time. The good news: you can use a Software SPI communication with the screen. The bad news: it is incredibly slow.

The screen requires this two libraries:

-Adafruit_ILI9340 (Library for the screen)

-Adafruit-GFX-Library (core graphics library)

In the next image you can see how to connect the Screen and two buttons with the Arduino.

To use the iShield iOS app you are going to need to download the iShield Arduino Library, here is a getting started using the Arduino IDE 1.0.5.

Find the code for this project at the end of this post.


Code

codeC/C++
#include <Nordic_nRF8001.h>
#include <RBL_nRF8001.h>
#include "iShield.h"
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"


#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif

// These are the pins used for the UNO
// for Due/Mega/Leonardo use the hardware SPI pins (which are different)
#define _sclk 7
#define _miso 6
#define _mosi 5
#define _cs 4
#define _dc 3
#define _rst 2

// Using software SPI is really not suggested, its incredibly slow
Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);
// Use hardware SPI
//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);

iShield myiShield;

bool flag = false;
bool flag2 = false;

String message;

void setup() {

  pinMode(buttonPin, INPUT);

  Serial.begin(9600);

  Serial.println("Setup TFT Screen ...");
  tft.begin();
  Serial.println("Setup BLE ...");
  ble_begin();
  tft.fillScreen(ILI9340_BLACK);
  tft.setRotation(3);
  tft.setCursor(0, 0);
  Serial.println("Finish setup ...");

}


void loop(void) {

  myiShield.readConsole();
  message = myiShield.incomingData();

  if(digitalRead(A1) == HIGH && flag == false){
    myiShield.writeConsole("RED Pressed");
    flag = true;
  }
  else if(digitalRead(A1) == LOW && flag == true){
    myiShield.writeConsole("RED Released");
    flag = false;
  }

  if(digitalRead(A0) == HIGH && flag2 == false){
    myiShield.writeConsole("GREEN Pressed");
    flag2 = true;
  }
  else if(digitalRead(A0) == LOW && flag2 == true){
    myiShield.writeConsole("GREEN Released");
    flag2 = false;
  }

  tft.fillRect(0,22,ILI9340_TFTHEIGHT,45,ILI9340_BLACK);
  tft.setTextColor(ILI9340_GREEN);
  tft.setTextSize(3);
  tft.setCursor(0, 0);
  tft.setTextColor(ILI9340_GREEN);
  tft.setTextSize(3);
  tft.println("iShield data > ");
  tft.println(message);
}

Schematics

IMG_0286.png
Img 0286

Comments

Similar projects you might like

iShield and nRF8001 Breakout example

Project tutorial by Victor Carreño

  • 1,913 views
  • 0 comments
  • 8 respects

Using iShield Gauge with potentiometer

Project tutorial by Victor Carreño

  • 1,569 views
  • 3 comments
  • 7 respects

iShield Weather Station

Project tutorial by Victor Carreño

  • 6,222 views
  • 0 comments
  • 14 respects

Bluetooth Security System

Project tutorial by Victor Carreño

  • 10,992 views
  • 2 comments
  • 35 respects

iShield - Hello World!

Project tutorial by Victor Carreño

  • 1,189 views
  • 0 comments
  • 2 respects

Arduino Dot Matrix Game Console

Project tutorial by Md. Khairul Alam

  • 9,026 views
  • 1 comment
  • 28 respects
Add projectSign up / Login