Showing posts with label microcontroller. Show all posts
Showing posts with label microcontroller. Show all posts

Interfacing SPI TFT with Arduino.

By // 20 comments:
Hey fellas!
It's been long since our last blog...but worry not! Here I'm back again with something new to try this time around. This blog will let you know how to interface a 1.8 inches SPI TFT with arduino. The task may get a bit tricky if someone just starts without taking a few things in consideration. So here we go!




Now what's with this "SPI" term? Why not just a TFT?
Well, that's because like you all must have known, there are 2 modes of transferring data, SERIAL & PARALLEL. When there are separate multiple data buses for data transfer, that's a Parallel Data Bus TFT or more generally known as a normal TFT. These types of displays will have a comparatively large no. of pins to connect (quite obvious), as 8 or 16 pins are for data bus alone and then the other ones too.
They generally take up all the space on an UNO or even may require a shield as well.

When there is a single data bus to transfer all the data, all the data is streamlined in a series and then pushed towards the receiving end. This type of TFT is called an SPI TFT, where SPI stands for SERIAL PERIPHERAL INTERFACE. Now we know what that un-abbreviated form says!

Also remember that this 1.8 inches SPI TFT has different pin connections on an UNO (or similar) board and the MEGA board. On MEGA, the SPI pins lie at 50,51,52 and 53. 

First of all, list of required items is as follows:
* Arduino UNO (or similar) x 1
* 1k ohm resistances x 5
* One-2-One connectors x 8

The TFT library comes pre-installed in Arduino version 1.0.5 and later.

Make the connections as mentioned below-

Reset
8
Dc (A0)
9
Cs
10
SDA
11 (UNO) or 51 (MEGA)
SCL
13 (UNO) or 52 (MEGA)
BKL
3.3v
Vcc
5v
Gnd
Gnd


Now instead of making the first 5 connections directly to Arduino, put a resistor of 1k or similar value between the TFT pin and the Arduino pin. That’s because the IO ports are 3.3v tolerant while the Vcc required is 5v. It is quite possible because of it’s non-standard chinese manufacturing.

Now, open the IDE and run the any sketch except the “BitmapLogo”. This sketch uses the SD card function and requires you to hook up the TFT with an SD card as well, which is definitely not a part of this article.

I’m putting a demo sketch that I ran successfully-

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1

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

// char array to print to the screen
char sensorPrintout[4];

void setup() {

  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // 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
  TFTscreen.stroke(255, 255, 255);
  // set the font size
  TFTscreen.setTextSize(2);
  // write the text to the top left corner of the screen
  TFTscreen.stroke(255, 0, 0);
  TFTscreen.text("IoT Freaks!\n ", 20, 0);
  TFTscreen.stroke(0, 255, 255);
  TFTscreen.text("Sensor value\n ", 12, 25);
  // ste the font size very large for the loop
  
}

void loop() {

  // Read the value of the sensor on A0
  String sensorVal = String(analogRead(A0));

  // convert the reading to a char array
  sensorVal.toCharArray(sensorPrintout, 4);

  TFTscreen.stroke(255, 255, 0);
  TFTscreen.setTextSize(5);
  TFTscreen.text(sensorPrintout, 34, 50);
  delay(550);
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.text(sensorPrintout, 34, 50);
}

This sketch requires a sensor at pin A0 to read it's value and then display it as text on  the TFT. So put any analog value sensor such as a potentiometer, an LDR, an IR pair or whatever you have.





Viola! I’m pretty much sure you’ll have it done then……

Be sure to buy the stuff mentioned in this blog by clicking on the link below-
http://www.ebay.in/usr/4d_innovations?_trksid=p2053788.m1543.l2754

The vendor's offering interesting and working hardware at quite handy rates. Go give it a try! :)

So until my next blog, this is it. As always, any problem you face and wish to discuss it, the comment boxes are always down there and you can reach me as well at iotfreaks@gmail.com

For more of these interesting stuff, like my page-
https://www.facebook.com/iotfreaks/

And our community,
https://www.facebook.com/projectsdunia/

Arduino-based Automatic Temperature Fan Speed Controller

By // 37 comments:
In many small or large industry, you may have seen such a lot of fan that speed is control according to the temperature of the place. Thus, during this article, we have presented a demo of that application. It's assumed that you have an idea of how to read reading from the temperature sensor IC. In industry
temperature range will be more than 100 oC  but here we will work on the very low range.
Block diagram of Temperature control FAN

block diagram of temperature control fan using arduino board
Block Diagram
Required Components 
  1. Arduino UNO board (buy from here arduino )
  2. Temperature sensor IC LM35( buy from here LM35 sensor )
  3. DC Fan
  4. resistor 1* 1K
  5. 16*2 LCD Display
  6. Power supply  
  7. Diode(1N4007) 
Circuit Diagram 
In this application, we use an arduino board to control the speed of the fan and a 16*2 LCD display to display the status of the fan. Here we use a diode in parallel with FAN to prevent it from the damage and a 9V battery to provide power to the fan.

circuit diagram of arduino based temperature control fan
Circuit Diagram
Code
Again like our previous projects, code for this projects is also very simple. Here we use an analogRead() function to get the value of temperature sensor and store that value in the variable.When this value will exceed the min_temp value then the fan will start otherwise its always off. Download the file to get the source code of this projects along with its circuit diagram.
source code of arduino based temperature control fan
Source Code
Download
In the below link you will get all the file required for this projects.

Video Demonstration