Monthly Archives: July, 2013

iPhone controlled Solar Powered Arduino Tank


More details:

Humanoid Biped Project

Iron Man faceplate hinge whit arduino and servo

Android phone used as a GSM shield for arduino

Your Image on an Arduino! – TFT LCD Screen Guide

Arduino Phone

What you need:

1.Arduino Uno

2.TFT Touch Shield

3.GPRS Shield


5.Custom ArduinoPhone Charge Circuit (or Lipo Rider)

6.Li-po battery

7.A shell (with 3D printer)

All components at here.


More details:

SainSmart 1.8 LCD / DHT-22 Temp / Humidity

I now have a DHT-22 Temperature and humidity module matched up with the SainSmart 1.8 TFT LCD. The tricky part of this project was converting floats to strings for the display. If you don’t need decimal point precision, you may not need this function, but it’s in there.

The DHT-22 connections and the SainSmart LCD connections are in the code.

Arduino TFT text example

This example demonstrates how to draw text on the
TFT with an Arduino. The Arduino reads the value
of an analog sensor attached to pin A0, and writes
the value to the LCD screen, updating every
quarter second.

This example code is in the public domain

Created 15 April 2013 by Scott Fitzgerald

Heavily modified to work with the DHT-22 code
by Steve Spence of


#include “TFT.h” // Arduino LCD library
#include “SPI.h” // Arduino SPI Library

// pin definition for the Uno
// SCL -> 13
// SDA -> 11
#define cs   10
#define dc   9
#define rst  8

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen
char tempPrintout[6];
char humPrintout[6];

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
// Fahrenheit conversion added by Steve Spence,

#include “DHT.h” //get the DHT library from

#define DHTPIN 2     // what pin we’re connected to

// Uncomment whatever type you’re using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin + (middle) of the sensor to +5V
// Connect pin S  (on the right) of the sensor to whatever your DHTPIN is (2)
// Connect pin – (on the left) of the sensor to GROUND
// Connect 10k resistor between S and +

int cycleTime = 2000;


float h;
float t;

void setup() {

// Put this line at the beginning of every sketch that uses the GLCD:

// clear the screen with a black background
TFTscreen.background(0, 0, 0);

// write the static text to the screen
// set the font color to white
// set the font size
// write the text to the top left corner of the screen
TFTscreen.text(“Temp (F)”,0,0);
// write the text to the top left corner of the screen
TFTscreen.text(“Humidity (%)”,0,60);
// ste the font size very large for the loop



void loop() {

// Read the value of the temp/humidity sensor on D2

// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
h = dht.readHumidity();
t = dht.readTemperature();
t = (t*1.8)+32; //C to F conversion

String tempVal = doubleToString(t, 0); // decimal places of precision
String humVal = doubleToString(h, 0); // decimal places of precision
// String sensorVal = String(1.234);

// convert the reading to a char array
tempVal.toCharArray(tempPrintout, 6);
humVal.toCharArray(humPrintout, 6);

// set the font color
// print the sensor value
TFTscreen.text(tempPrintout, 0, 25);
TFTscreen.text(humPrintout, 0, 85);
// wait for a moment
// erase the text you just wrote
TFTscreen.text(tempPrintout, 0, 25);
TFTscreen.text(humPrintout, 0, 85);

//Rounds down (via intermediary integer conversion truncation)
String doubleToString(double input,int decimalPlaces){
String string = String((int)(input*pow(10,decimalPlaces)));
if(abs(input)<1 p=””>if(input>0)
string = “0”+string;
else if(input<0 p=””>string = string.substring(0,1)+”0″+string.substring(1);
return string.substring(0,string.length()-decimalPlaces)+”.”+string.substring(string.length()-decimalPlaces);
else {
return String((int)input);

Robotic Remote Control Car Using Touch Screen Remote

Robotic car control using STM32F4 discovery broad(ARM Cortex M4)and SainSmart 3.2″ TFT LCD. On broad Accelerometer is also used to control the car.

Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens

** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens
** Readily found on eBay or
** The LCD2004 module appears to be identical to one marketed by YwRobot
** Address pins 0,1 & 2 are all permenantly tied high so the address is fixed at 0x27
** Written for and tested with Arduino 1.0
** This example uses F Malpartida’s NewLiquidCrystal library. Obtain from:
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
int n = 1;
LiquidCrystal_I2C       lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
  lcd.begin (20,4);
// Switch on the backlight
  lcd.home ();                   // go home
  lcd.print(“SainSmart I2C test”);
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print(“F Malpartida library”);
  lcd.setCursor ( 0, 2 );        // go to the next line
  lcd.print(“Test By Edward Comer”);
  lcd.setCursor ( 0, 3 );        // go to the next line
  lcd.print(“Iteration No: “);
void loop()
  // Backlight on/off every 3 seconds
  lcd.setCursor (14,3);        // go col 14 of line 3
  lcd.setBacklight(LOW);      // Backlight off
  lcd.setBacklight(HIGH);     // Backlight on

SainSmart 1.8 SPI LCD Module with MicroSD LED Backlight

Reblogged from:

A few months ago I’d purchased a SainSmart 1.8 SPI LCD Module with MicroSD LED Backlight and it kind of just sat on my dresser waiting for a rainy day. Last weekend it was very rainy and I finally rolled up my sleeves and got it working. I’d gotten some new jumper cables (for arduino, not car) in the mail and made things a lot easier, as all mine were male-male. Now I have a variety of male-male, female-female, and male-female. Kind of sounds like porn categories.


There were a lot of good tutorials on how to get the LCD working, and I was able to get it “Option 1″ going in short order. It was, however, very slow. My next step was to stick in on a breadboard along with one of my Ping sensors so that I could have some data to output. For some reason, I struggled with converting the int value to a char in C++.  I’m fairly new with C++ and it seemed to be a royal pain in the ass. What’s more, the Arduino seems to run a rather limitted version of C++.

My next road bump was getting the LCD set up in SPI mode – “Option 2″. It is certainly worth the hastle, as it is much faster. The documentation that I found on Sainsmart’s site gave very good instructions for setting it up in the “slow” mode, but not so much for the fast. It took a little bit of Googling, and some instructions on a German message board for me to get it working. The adafruit learning system site has a good tutorial on the slow mode.


This is the LCD configured for SPI mode. (The wires on the right can be disregarded; they are for the Ping sensor.) You don’t have to use the sensor shield, but if you actually want some data to output to the LCD, you might want some extra gizmos attached, and the breadboard can take up space and make things feel clunky. I’m not going to pretend that I know what these pins do, but this should help get it working if anyone (including me) needs a reference.

CS     10
RES    8
DC     9
SDA    11
SCL    13  # Pretty sure this has to be 13 for Arduino Uno R3
VCC    5v

And then you can use the code from the example.

#define cs 10   // for MEGAs you probably want this to be pin 53
#define dc 9
#define rst 8  // you can also connect this to the Arduino reset

#include <ST7735.h>
#include <SPI.h>

// Option 1: use any pins but a little slower
//ST7735 tft = ST7735(cs, dc, mosi, sclk, rst);  

// Option 2: must use the hardware SPI pins 
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be 
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
ST7735 tft = ST7735(cs, dc, rst);

That’s it. I did notice, however, that some of the pins seem to become unavailable once the tft is initialized. I tried using pin 12, for example, and it did not work well. Pin 2 did. That’s all I have to say about that.