Friday, March 30, 2018

Arduino 2.8" 240x320 SPI TFT screen


Two weeks ago I bought a 2.8" 320x240 pixels RGB color TFT display having graphics driver chip ILI9341 and using Serial Peripheral Interface SPI for communication with Arduino board. You can find the display details in this link:
https://uge-one.com/arduino-2.8-inch-spi-tft-module.html?search=tft&description=true

The display has 8 pins as shown in the picture below. Unfortunately, this screen does no have Chip Select CS (Slave Select SS) pin which is required if you are interfacing multiple SPI devices. Apart from the power pins (GND and VCC), this display needs only 4 digital pins to operate successfully and these pins are: CLK, MOSI, RES, and DC. 

Pins BLK and MISO are optional and are not mandatory for operation of the display. In case you want to connect MISO pin with Arduino board, you can connect it directly because Arduino digital pins read any voltage level above 1.5V as digital HIGH.





This display is powered through VCC pin using 3.3V and for this reason all incoming signal levels should be within 3.3V. Powering this display with 5V will not harm or damage the screen immediately, but will turn the whole screen into white. These signal levels can be achieved using the simple voltage divider circuit as the shown in the images below. 


The following is wiring of this display with Arduino Uno using hardware SPI interface (click the image to see it on full scale).




The following is wiring of this display with Arduino Uno using software SPI interface (click the image to see it on full scale). You can use different digital pins and define them in the code.





From software side of view, this display can be integrated with Arduino (I am using Arduino IDE 1.8.3) using one of two options:


First option:

Using both: Adafruit GFX library and Adafruit ILI9341 library. You can download these libraries using the library manager in Arduino IDE as shown in the images below. 







To kick off the coding, the code below is used to draw a black screen with a white rectangle drawn in the middle.


#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RES 8

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC,TFT_RES);

// In case you want to use software SPI, define pin numbers above and uncomment the line below
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RES, TFT_MISO);

void setup() {
tft.begin();
tft.setRotation(1);    // Use screen horizontally
tft.fillRect(0,0,320,240,0x0000);     //fill the screen with black rectangle
tft.fillRect(80,60,160,120,0xFFFF);     // draw white rectangle in the middle
}

void loop(void) {
 
}

Second option:

Using UCGlib library. This library also is available from Arduino library manager. To learn more about this library you can go to reference page from this link




To make things easier, here is a very simple code for this library as well.


#include "SPI.h"
#include "Ucglib.h"

#define TFT_DC 9
#define TFT_CS 10
#define TFT_RES 8

// Hardware SPI
Ucglib_ILI9341_18x240x320_HWSPI ucg(TFT_DC,TFT_CS,TFT_RES);

// In case you want to use software SPI, define pin numbers above and uncomment the line below
//Ucglib_ILI9341_18x240x320_SWSPI ucg(TFT_CLK,TFT_MOSI,TFT_DC, TFT_CS,TFT_RES);

void setup() {
ucg.setRotate90();
ucg.setColor(0,0,0);
ucg.drawBox(0,0,320,240);
ucg.setColor(255,255,255);
ucg.drawBox(80,60,160,120);
}

void loop() {

}

Keywords:

Egypt UGE 2.8" (2.8 inch) SPI RGB TFT LCD screen display 320x240 wiring circuit diagram

Egypt UGE 2.8" (2.8 inch) SPI RGB TFT LCD screen display 320x240 code

2.8" (2.8 inch) SPI RGB TFT LCD screen display 320x240 driver IC chip ILI9341

SPI TFT display without Chip Select CS pin

SPI TFT display without Slave Select SS pin

8 pin SPI TFT LCD screen display 320x240

Cheap Chinese SPI TFT LCD screen display 320x240

Friday, March 16, 2018

Programming Atmel ATMEGA328-PU microcontroller using Arduino Mega board

The following method is used if ATMEGA328-PU microcontroller will be used with external oscillator 16 MHz. Before going on any steps, you should download Arduino IDE and install it. In this tutorial I am using Arduino IDE version 1.8.3

We want to use Arduino Mega 2560 as an ISP programmer for Atmel ATMEGA328-20PU DIP package microcontroller. To do this, we will do some steps for software and hardware.

A. Make the programmer

First: Software preparation:
[1] Before any wiring or creating any mess, connect Arduino Mega 2560 board to your PC using the USB cable

[2] Open Arduino IDE -> File -> Examples -> 11.Arduino ISP -> ArduinoISP.
By doing this "ArduinoISP" sketch will be opened. Keep the sketch as it is without any modification.

[3] Select Tools -> Board -> Arduino/Genuino Mega or Mega2560

[4] Select Tools -> Processor -> ATMEGA2560

[5] Select the correct COM port from Tools -> Port

[6] Select Sketch -> Upload

[7] By uploading the sketch, we have finished the software part.

Second: Hardware preparation:

[1] As many references said, we need 10 uF electrolytic capacitor (in my case I used a 33 uF capacitor which was available for me and it did the job). Connect the positive (long) lead of the capacitor to RESET pin of Arduino Mega 2560 and the short (negative) lead of the capacitor to GND pin of Arduino Mega. This capacitor is needed to disable resetting Arduino Mega.

[2] Now, we have turned our Arduino Mega 2560 to a programmer.

Saturday, March 3, 2018

Nestle water bottle dimensions

Key words:

Nestle Egypt 1.5 liter PET mineral water bottle dimensions

Nestle Egypt 1.5 liter PET mineral water bottle size

Standard 1.5 liter PET mineral water bottle dimensions

Water bottle dimensions for packaging design

Water bottle dimensions for cardboard box design