<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Electronics and DIY Archives - Tutorial45</title>
	<atom:link href="https://tutorial45.com/category/electronics-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tutorials and Tech</description>
	<lastBuildDate>Tue, 27 Feb 2024 08:16:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://tutorial45.com/wp-content/uploads/2015/04/cropped-text125d52-32x32.png</url>
	<title>Electronics and DIY Archives - Tutorial45</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Arduino Touch Screen Project</title>
		<link>https://tutorial45.com/arduino-with-touch-screen/</link>
					<comments>https://tutorial45.com/arduino-with-touch-screen/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Andreea]]></dc:creator>
		<pubDate>Tue, 27 Feb 2024 08:16:01 +0000</pubDate>
				<category><![CDATA[Arduino Projects]]></category>
		<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">https://tutorial45.com/?p=10457</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/arduino-with-touch-screen/">Arduino Touch Screen Project</a></p>
<p>The AZ-Delivery 2.4” TFT LCD Touch Display boasts 320x 240 pixels with 16-bit color. It has Touch capabilities, a built-in SD card drive, and plugs straight onto the top of an Arduino UNO or Mega. Amazon charges less than £11 for this device. It offers a major step up from the tiny SSD1306 128&#215;64 monochrome ... </p>
<p class="read-more-container"><a title="Arduino Touch Screen Project" class="read-more button" href="https://tutorial45.com/arduino-with-touch-screen/#more-10457" aria-label="More on Arduino Touch Screen Project">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/arduino-with-touch-screen/">Arduino Touch Screen Project</a></p>

<p class="wp-block-paragraph">The AZ-Delivery 2.4” TFT LCD Touch Display boasts 320x 240 pixels with 16-bit color. It has Touch capabilities, a built-in SD card drive, and plugs straight onto the top of an Arduino UNO or Mega. Amazon charges less than £11 for this device. It offers a major step up from the tiny SSD1306 128&#215;64 monochrome display.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="998" src="https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1-1024x998.jpg" alt="" class="wp-image-10458" style="width:328px;height:320px" srcset="https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1-1024x998.jpg 1024w, https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1-300x293.jpg 300w, https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1-768x749.jpg 768w, https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1-1170x1141.jpg 1170w, https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1-585x570.jpg 585w, https://tutorial45.com/wp-content/uploads/2020/10/arduino-touch-screen-1.jpg 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p class="wp-block-paragraph">The TFT screen is much larger than the SSD1306 128&#215;64 and much more colourful. The package includes an SD card reader on the underside and a stylus for accurate touch-screen control.</p>



<p class="wp-block-paragraph">AZ-Delivery usually supply an e-book (pdf document for download) with their boards. The German version comes first followed by other languages. This has just become available and provides setup instructions and a demonstration graphics only sketch.</p>



<p class="wp-block-paragraph">The underside of the board has labels on the pins. As the board is an <a href="https://tutorial45.com/arduino-shields-for-arduino/">Arduino shield</a>, it will only fit on a UNO in one position. The SD card reader sits between USB and the power socket. It will also plug into and <a href="https://tutorial45.com/comparing-microcontrollers-arduino-mega-vs-uno/">Arduino MEGA</a> 2560. J1 and J2 fit into the digital pins, covering D0 to D13, while J3 and J4 fit into the analog and power pins.</p>



<p class="wp-block-paragraph">LCD_D0 to LCD_D7 provide an 8-bit bus with the other LCD pins on J3.</p>



<p class="wp-block-paragraph">The card reader uses the SPI pins, D11, D12, and D13 with chip select on D10. (Not D4 as used in all the Arduino example sketches.)</p>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img decoding="async" width="850" height="557" src="https://tutorial45.com/wp-content/uploads/2020/10/touchScreenArduino.jpg" alt="" class="wp-image-10474" style="width:850px;height:557px" srcset="https://tutorial45.com/wp-content/uploads/2020/10/touchScreenArduino.jpg 850w, https://tutorial45.com/wp-content/uploads/2020/10/touchScreenArduino-300x197.jpg 300w, https://tutorial45.com/wp-content/uploads/2020/10/touchScreenArduino-768x503.jpg 768w, https://tutorial45.com/wp-content/uploads/2020/10/touchScreenArduino-585x383.jpg 585w" sizes="(max-width: 850px) 100vw, 850px" /></figure>
</div>


<p class="wp-block-paragraph">This picture shows the underside of the board with an SD card inserted in the card reader.</p>



<p class="wp-block-paragraph">I searched the Web for drivers and examples and found much praise for the TFT graphics, reports of problems with the Touch control, and nothing about the SD card reader on this board.</p>



<p class="wp-block-paragraph">In the end, I installed several libraries (with all dependencies): Adafruit GFX, Adafruit TFT LCD, Adafruit TouchScreen, Adafruit ILI9341, MCUFRIEND_kbv, and SPFD5408-master. (The last 2 are not essential but include some interesting examples). The SD library is included in the basic Arduino set.</p>



<p class="wp-block-paragraph">I’ve used GFX with mono displays such as SSD1306 and soon got the TFT display working. The following script gives some idea about what it can do. I’ve included pixels, text (of varying sizes), lines, rectangles, triangles, squares, graphs, screen rotation, and text on a path. I was very impressed with the clarity, speed, brightness, and colors produced.</p>



<p class="wp-block-paragraph">Here is my first graphics sketch:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="//  AZ-Delivery 2.4&quot; TFT LCD touch shield Demo
//          Shield on Arduino UNO
//  +++ Tony Goodhew 17th September 2020 +++
//  Tutorial45.com

// Essential Adafruit GFX Libraries
#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_TFTLCD.h&gt;

#define LCD_CS A3     // Chip Select goes to Analog 3
#define LCD_CD A2     // Command/Data goes to Analog 2
#define LCD_WR A1     // LCD Write goes to Analog 1
#define LCD_RD A0     // LCD Read goes to Analog 0
#define LCD_RESET A4  // Can alternately just connect to Arduino's reset pin

// Colour definitions for 64k colour mode
// Bits 0..4 -&gt;   Blue 0..4
// Bits 5..10 -&gt;  Green 0..5
// Bits 11..15 -&gt; Red 0..4
#define BLACK 0x0000
#define WHITE 0xFFFF
#define GREY 0x7BEF
#define LT_GREY 0xC618
#define GREEN 0x07E0
#define LIME 0x87E0
#define BLUE 0x001F
#define RED 0xF800
#define AQUA 0x5D1C
#define YELLOW 0xFFE0
#define MAGENTA 0xF81F
#define CYAN 0x07FF
#define DK_CYAN 0x03EF
#define ORANGE 0xFCA0
#define PINK 0xF97F
#define BROWN 0x8200
#define VIOLET 0x9199
#define SILVER 0xA510
#define GOLD 0xA508
#define NAVY 0x000F
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
// Put colours in an array for random colour access
int tftColours[] = {GREY,LT_GREY,GREEN,LIME,BLUE,RED,AQUA,YELLOW,MAGENTA,CYAN,DK_CYAN,
                   ORANGE,PINK,BROWN,VIOLET,SILVER,GOLD,NAVY,MAROON,PURPLE,OLIVE, WHITE};

// Create the TFT object using all pin assignments
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// =========== SETUP ================
void setup() {
  Serial.begin(9600); // Useful for debugging
  tft.reset();
  tft.begin(0x9341);  // SDFP5408
  tft.setRotation(3); // 320 wide by 240 high - reset button on left
  tft.fillScreen(BLACK);
  tft.setCursor(30, 50);
  tft.setTextColor(RED);
  tft.setTextSize(3);
  tft.println(&quot;AZ-Delivery&quot;);
  tft.setTextColor(YELLOW);
  tft.setCursor(30, 90);
  tft.println(&quot;2.4 TFT LCD&quot;);
  tft.setCursor(30, 120);
  tft.println(&quot;Touch Display&quot;);
  tft.setCursor(30, 150);
  tft.println(&quot;&amp; SD Drive&quot;);
  tft.setCursor(30, 200);
  tft.setTextColor(RED);
  tft.setTextSize(2);
  tft.println(&quot;Tutorial45.com&quot;);
  delay(4000);
  tft.fillScreen(BLACK); // Clears the screen
  
  // Display some Pixels
  for (int m = 0; m &lt;= 4000; m++)  {     // 4000 random pixels
    int xx = random(320);
    int yy = random(240);
    tft.drawPixel(xx, yy, tftColours[random(22)]);   
  }
  delay(2000);
  tft.fillScreen(BLACK);

  int x = 1;
  int y = 50;
  int h = 50;
  int w = 50;
  int xj = 160;
  int yj = 170;
  int t = RED;

  // Quilt
  for (int xx=0; xx &lt; 320; xx = xx + 32){
    for (int yy = 0; yy &lt; 240; yy = yy + 24){
      tft.fillRect(xx,yy,32,24,tftColours[random(22)]);
    }
  }

  delay(2000);
  tft.fillScreen(BLACK);
  // Grid
  tft.fillScreen(BLACK);
  for (int x =0; x &lt; 320; x=x +10) {
    tft.drawFastVLine(x+5, 0, 240, RED);
  }
  for (int y = 0; y &lt; 240; y = y + 10) {
    tft.drawFastHLine(0, y+3, 320 , BLUE);
  }
  delay(2000);
  tft.fillScreen(BLACK);
  for (int x = 60; x &lt; 200; x=x +25) {
    int yy = x-10;
    tft.drawRect(x,yy,40,45,tftColours[random(22)]); 
    //drawRect( x,  y,  w,  h, c)
  }
  delay(2000);
  // Rectangles
  tft.fillScreen(BLACK);
  for (int x = 60; x &lt; 200; x=x +25) {
    int yy = x-10;
    tft.fillRect(x,yy,40,45,tftColours[random(22)]); 
    //fillRect( x,  y,  w,  h, c)
  }
  delay(2000);
  tft.fillScreen(BLACK);
  int r = 5;
  for (int x = 60; x &lt; 200; x=x +25) {
    int yy = x-10;
    tft.drawRoundRect(x,yy,40,45,r,tftColours[random(22)]);
    r = r + 3; 
    //drawRoundRect( x,  y,  w,  h, r, c)
  }
  delay(2000);
  tft.fillScreen(BLACK);
  r = 5;
  for (int x = 60; x &lt; 200; x=x +25) {
    int yy = x-10;
    tft.fillRoundRect(x,yy,40,45,r,tftColours[random(22)]); 
    //fillRoundRect( x,  y,  w,  h, r, c)
    r = r + 3;
  }
  delay(2000);
  // A few circles
  tft.fillScreen(BLACK);
  for (int r = 120;r &gt; 5; r=r-10){
    tft.fillCircle(80, 40, r, tftColours[random(22)]);
    delay(50);
  }
  for (int r = 5;r &lt;120; r=r+10){
    tft.fillCircle(random(200), random(120), r, tftColours[random(22)]);
    delay(50);
  } 
  delay(2000);
  tft.fillScreen(BLACK);
  for (int r = 120;r &gt; 5; r=r-10){
    tft.drawCircle(80 + random(60), 40 + random(70), r, tftColours[random(22)]);
  }
  delay(1000);
  for (int r = 5;r &lt;120; r=r+10){
    tft.drawCircle(random(200), random(120), r, tftColours[random(22)]);
  } 
  delay(2000);
  
  // Draw Sine and Cosine curves  
  float sine[300];
  float cosine[300];
  tft.fillScreen(BLACK);
  tft.setTextColor(YELLOW);
  tft.setCursor(10,220);
  tft.setTextSize(2);
  tft.println(&quot;Sine Curve&quot;);
  tft.setTextColor(RED);
  tft.setCursor(125,20);
  tft.println(&quot;Cosine Curve&quot;);
  tft.drawFastHLine(9, 120, 300 ,BLUE);
  for (int i = 0; i &lt; 300; i++){
    sine[i] = (sin(radians(i *1.2))) * -1; 
    tft.drawPixel(i+9,int(sine[i]*100+120),YELLOW);
    cosine[i] = (cos(radians(i *1.2))) * -1; 
    tft.drawPixel(i+9,int(cosine[i]*100+120),RED);
  }
  delay(2000);
  // Screen rotation - 4 0ptions 0, 90 180 and 270 degrees 
  tft.fillScreen(BLACK);
  tft.setCursor(25,32);   // Title splash
  tft.print(&quot;Rotate Screen&quot;);
  delay(1000);
  tft.fillScreen(BLACK);
  for (int rt = 0; rt &lt;= 3  ; rt++){
    tft.setRotation(rt % 4);               // Values 0..3
    tft.fillScreen(BLACK);
    int cw = WHITE;
    tft.fillTriangle(0,0,0,30,30,0,cw);     // (x,y,x1,y1,x2,y2,colour)
    tft.fillTriangle(0,15,40,50,15,0,cw);
    tft.fillTriangle(15,0,50,40,0,15,cw);
    tft.fillTriangle(40,50,50,40,20,20,cw);
    tft.setTextSize(2);                     // Middle size
    tft.setTextColor(BLACK); 
    tft.setCursor(5,5);             
    tft.println(rt % 4);
    tft.setTextColor(RED);
    tft.setCursor(50,50);
    tft.setTextSize(3);
    tft.println(&quot;TFT LCD&quot;);
    delay(1000);  
  }
  tft.setRotation(3);
  tft.fillScreen(BLACK);
  // Text Sizes

  tft.setTextSize(1);                // Normal 1:1 pixel scale
  tft.setTextColor(WHITE);           // Draw white text
  tft.setCursor(0,0);                // Start at top-left corner
  tft.println(&quot;Text Sizes\n&quot;);
  tft.setTextSize(2);                // Medium
  tft.println(&quot;AZ-Delivery\n&quot;);
  tft.setTextSize(3);                // Large - rather blocky  
  tft.println(&quot;TFT LCD 320x240\n&quot;);
  tft.setTextSize(4);                // Larger - very blocky  
  tft.println(&quot;Touch\n&quot;);
  tft.setTextSize(5);                // Largest - very blocky  
  tft.println(&quot;2.4 inch&quot;);
  tft.setTextSize(1);
  tft.setTextColor(BLUE);
  tft.setCursor(220,220);
  tft.println(&quot;Tutorial45.com&quot;);
  delay(2000);
  
  // Text along a path
  tft.fillScreen(BLACK);
  char msg2[] = &quot;+ TFT LCD+Arduino=MAGIC +&quot;;
  for (int n = 0; n &lt; 25; n++){
    char ch = msg2[n];
    int p = n*12; // was 9
    float y1 = (cos(radians(p *2.8125)) * -1);
    int yy = int(y1 *25.0 + 100);
    tft.drawChar(p + 5, yy, ch, RED, BLACK, 2);
  }
  delay(4000);
  tft.fillScreen(BLACK);
  char msg[] =  &quot;+++ Tutorial45.com +++&quot;;
  tft.fillScreen(BLACK);
  for (int n = 0; n &lt; 22; n++){
    char ch = msg[n];
    int p = n*9;
    float y1 = (sin(radians(p *2.8125)) * -1);
    int yy = int(y1 *25.0 + 100);
    tft.drawChar(p + 60, yy, ch, GREEN, BLACK, 1);
  }
  tft.setTextSize(1);
  tft.setTextColor(BLUE);
  tft.setCursor(220,120);
  tft.println(&quot;Finished&quot;);
}

// ------------ LOOP NOT NEEDED --------------------

void loop() {}" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">//  AZ-Delivery 2.4&quot; TFT LCD touch shield Demo</span></span>
<span class="line"><span style="color: #768390">//          Shield on Arduino UNO</span></span>
<span class="line"><span style="color: #768390">//  +++ Tony Goodhew 17th September 2020 +++</span></span>
<span class="line"><span style="color: #768390">//  Tutorial45.com</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Essential Adafruit GFX Libraries</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_GFX.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_TFTLCD.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A3</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Chip Select goes to Analog 3</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A2</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Command/Data goes to Analog 2</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A1</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Write goes to Analog 1</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A0</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Read goes to Analog 0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A4</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// Can alternately just connect to Arduino&#39;s reset pin</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Colour definitions for 64k colour mode</span></span>
<span class="line"><span style="color: #768390">// Bits 0..4 -&gt;   Blue 0..4</span></span>
<span class="line"><span style="color: #768390">// Bits 5..10 -&gt;  Green 0..5</span></span>
<span class="line"><span style="color: #768390">// Bits 11..15 -&gt; Red 0..4</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x0000</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFFF</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">GREY</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x7BEF</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LT_GREY</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xC618</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x07E0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LIME</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x87E0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x001F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF800</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">AQUA</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x5D1C</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFE0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAGENTA</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF81F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">CYAN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x07FF</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">DK_CYAN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x03EF</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">ORANGE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFCA0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">PINK</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF97F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BROWN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x8200</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">VIOLET</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x9199</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">SILVER</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xA510</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">GOLD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xA508</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">NAVY</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x000F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAROON</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x7800</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">PURPLE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x780F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">OLIVE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x7BE0</span></span>
<span class="line"><span style="color: #768390">// Put colours in an array for random colour access</span></span>
<span class="line"><span style="color: #ADBAC7">int tftColours[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {GREY,LT_GREY,GREEN,LIME,BLUE,RED,AQUA,YELLOW,MAGENTA,CYAN,DK_CYAN,</span></span>
<span class="line"><span style="color: #ADBAC7">                   ORANGE,PINK,BROWN,VIOLET,SILVER,GOLD,NAVY,MAROON,PURPLE,OLIVE, WHITE};</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Create the TFT object using all pin assignments</span></span>
<span class="line"><span style="color: #ADBAC7">Adafruit_TFTLCD </span><span style="color: #DCBDFB">tft</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// =========== SETUP ================</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Useful for debugging</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">reset</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0x9341</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// SDFP5408</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setRotation</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// 320 wide by 240 high - reset button on left</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;AZ-Delivery&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">90</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;2.4 TFT LCD&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Touch Display&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">150</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;&amp; SD Drive&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Tutorial45.com&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">4000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Clears the screen</span></span>
<span class="line"><span style="color: #ADBAC7">  </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Display some Pixels</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int m </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; m </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4000</span><span style="color: #ADBAC7">; m</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">)  {     </span><span style="color: #768390">// 4000 random pixels</span></span>
<span class="line"><span style="color: #ADBAC7">    int xx </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">320</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(xx, yy, tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);   </span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  int x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int h </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int w </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int xj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">160</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int yj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">170</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int t </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Quilt</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int xx</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; xx </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">320</span><span style="color: #ADBAC7">; xx </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> xx </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; yy </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">; yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> yy </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">24</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">      tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(xx,yy,</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">24</span><span style="color: #ADBAC7">,tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Grid</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int x </span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; x </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">320</span><span style="color: #ADBAC7">; x</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawFastVLine</span><span style="color: #ADBAC7">(x</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawFastHLine</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">320</span><span style="color: #ADBAC7"> , </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">; x </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">; x</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawRect</span><span style="color: #ADBAC7">(x,yy,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">,tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]); </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">//drawRect( x,  y,  w,  h, c)</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Rectangles</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">; x </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">; x</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(x,yy,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">,tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]); </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">//fillRect( x,  y,  w,  h, c)</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">; x </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">; x</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawRoundRect</span><span style="color: #ADBAC7">(x,yy,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">,r,tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);</span></span>
<span class="line"><span style="color: #ADBAC7">    r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">//drawRoundRect( x,  y,  w,  h, r, c)</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">; x </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">; x</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillRoundRect</span><span style="color: #ADBAC7">(x,yy,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">,r,tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]); </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">//fillRoundRect( x,  y,  w,  h, r, c)</span></span>
<span class="line"><span style="color: #ADBAC7">    r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// A few circles</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">;r </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">; r</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">r</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillCircle</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">80</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">, r, tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">;r </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">; r</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">r</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillCircle</span><span style="color: #ADBAC7">(</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">), </span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">), r, tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  } </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">;r </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">; r</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">r</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawCircle</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">80</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">), </span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">70</span><span style="color: #ADBAC7">), r, tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">;r </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">; r</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">r</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawCircle</span><span style="color: #ADBAC7">(</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">), </span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">), r, tftColours[</span><span style="color: #DCBDFB">random</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">)]);</span></span>
<span class="line"><span style="color: #ADBAC7">  } </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Draw Sine and Cosine curves  </span></span>
<span class="line"><span style="color: #ADBAC7">  float sine[</span><span style="color: #6CB6FF">300</span><span style="color: #ADBAC7">];</span></span>
<span class="line"><span style="color: #ADBAC7">  float cosine[</span><span style="color: #6CB6FF">300</span><span style="color: #ADBAC7">];</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">220</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Sine Curve&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">125</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Cosine Curve&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">drawFastHLine</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">300</span><span style="color: #ADBAC7"> ,</span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int i </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; i </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">300</span><span style="color: #ADBAC7">; i</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    sine[i] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> (</span><span style="color: #DCBDFB">sin</span><span style="color: #ADBAC7">(</span><span style="color: #DCBDFB">radians</span><span style="color: #ADBAC7">(i </span><span style="color: #F47067">*</span><span style="color: #6CB6FF">1.2</span><span style="color: #ADBAC7">))) </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">,</span><span style="color: #DCBDFB">int</span><span style="color: #ADBAC7">(sine[i]</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">100</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">),</span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    cosine[i] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> (</span><span style="color: #DCBDFB">cos</span><span style="color: #ADBAC7">(</span><span style="color: #DCBDFB">radians</span><span style="color: #ADBAC7">(i </span><span style="color: #F47067">*</span><span style="color: #6CB6FF">1.2</span><span style="color: #ADBAC7">))) </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">,</span><span style="color: #DCBDFB">int</span><span style="color: #ADBAC7">(cosine[i]</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">100</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">),</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Screen rotation - 4 0ptions 0, 90 180 and 270 degrees </span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">);   </span><span style="color: #768390">// Title splash</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Rotate Screen&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int rt </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; rt </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">  ; rt</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setRotation</span><span style="color: #ADBAC7">(rt </span><span style="color: #F47067">%</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">);               </span><span style="color: #768390">// Values 0..3</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    int cw </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillTriangle</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,cw);     </span><span style="color: #768390">// (x,y,x1,y1,x2,y2,colour)</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillTriangle</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">15</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">15</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,cw);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillTriangle</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">15</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">15</span><span style="color: #ADBAC7">,cw);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillTriangle</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">,cw);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);                     </span><span style="color: #768390">// Middle size</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">); </span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">);             </span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(rt </span><span style="color: #F47067">%</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;TFT LCD&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);  </span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setRotation</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Text Sizes</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);                </span><span style="color: #768390">// Normal 1:1 pixel scale</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7">);           </span><span style="color: #768390">// Draw white text</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">);                </span><span style="color: #768390">// Start at top-left corner</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Text Sizes</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);                </span><span style="color: #768390">// Medium</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;AZ-Delivery</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);                </span><span style="color: #768390">// Large - rather blocky  </span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;TFT LCD 320x240</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">);                </span><span style="color: #768390">// Larger - very blocky  </span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Touch</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">);                </span><span style="color: #768390">// Largest - very blocky  </span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;2.4 inch&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">220</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">220</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Tutorial45.com&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Text along a path</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  char msg2[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;+ TFT LCD+Arduino=MAGIC +&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int n </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; n </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">; n</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    char ch </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> msg2[n];</span></span>
<span class="line"><span style="color: #ADBAC7">    int p </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> n</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">12</span><span style="color: #ADBAC7">; </span><span style="color: #768390">// was 9</span></span>
<span class="line"><span style="color: #ADBAC7">    float y1 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> (</span><span style="color: #DCBDFB">cos</span><span style="color: #ADBAC7">(</span><span style="color: #DCBDFB">radians</span><span style="color: #ADBAC7">(p </span><span style="color: #F47067">*</span><span style="color: #6CB6FF">2.8125</span><span style="color: #ADBAC7">)) </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">int</span><span style="color: #ADBAC7">(y1 </span><span style="color: #F47067">*</span><span style="color: #6CB6FF">25.0</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawChar</span><span style="color: #ADBAC7">(p </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">, yy, ch, </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">4000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  char msg[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">&quot;+++ Tutorial45.com +++&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int n </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; n </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">; n</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    char ch </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> msg[n];</span></span>
<span class="line"><span style="color: #ADBAC7">    int p </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> n</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    float y1 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> (</span><span style="color: #DCBDFB">sin</span><span style="color: #ADBAC7">(</span><span style="color: #DCBDFB">radians</span><span style="color: #ADBAC7">(p </span><span style="color: #F47067">*</span><span style="color: #6CB6FF">2.8125</span><span style="color: #ADBAC7">)) </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    int yy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">int</span><span style="color: #ADBAC7">(y1 </span><span style="color: #F47067">*</span><span style="color: #6CB6FF">25.0</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">drawChar</span><span style="color: #ADBAC7">(p </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">, yy, ch, </span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">220</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Finished&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// ------------ LOOP NOT NEEDED --------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">() {}</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="479" height="346" src="https://tutorial45.com/wp-content/uploads/2020/10/black-screen.jpg" alt="" class="wp-image-10475" srcset="https://tutorial45.com/wp-content/uploads/2020/10/black-screen.jpg 479w, https://tutorial45.com/wp-content/uploads/2020/10/black-screen-300x217.jpg 300w" sizes="(max-width: 479px) 100vw, 479px" /></figure>
</div>


<h2 class="wp-block-heading">Color picking</h2>



<p class="wp-block-paragraph">Normally, when setting the color of an RGB LED, you have a range of 0-255 (0-FF hex) for each RGB component, which gives white = F, red = FF000, green FF00, and blue = FF. This is a 24-bit color and takes 3 bytes.  224 gives 16,777,216 different colors. The TFT screen is a 16-bit color device that can display 65,536 colors – more than enough. Here, the range is limited to 5 bits each for red and blue and 6 for green. (Our eyes are more sensitive to green, so It gets the extra bit of accuracy.)</p>



<figure class="wp-block-table"><table style="font-size: 11px"><tbody><tr><td style="background-color: tomato"><strong>R4</strong></td><td style="background-color: tomato"><strong>R3</strong></td><td style="background-color: tomato"><strong>R2</strong></td><td style="background-color: tomato"><strong>R1</strong></td><td style="background-color: tomato"><strong>R0</strong></td><td style="background-color: lightgreen"><strong>G5</strong></td><td style="background-color: lightgreen"><strong>G4</strong></td><td style="background-color: lightgreen"><strong>G3</strong></td><td style="background-color: lightgreen"><strong>G2</strong></td><td style="background-color: lightgreen"><strong>G1</strong></td><td style="background-color: lightgreen"><strong>G0</strong></td><td style="background-color: lightblue"><strong>B4</strong></td><td style="background-color: lightblue"><strong>B3</strong></td><td style="background-color: lightblue"><strong>B2</strong></td><td style="background-color: lightblue"><strong>B1</strong></td><td style="background-color: lightblue"><strong>B0</strong></td></tr style="background-color: lightblue"></tbody></table></figure>



<p class="wp-block-paragraph">To convert a 24-bit colour to a 16-bit colour held in integers r, g and b, each with range 0 – 255.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="// Convert 24-bit colours to 16-bit colours
// Tony Goodhew 22 Sept 2020
// Tutorial45.com
void setup() {
  Serial.begin(9600);
  int r = 255;
  int g = 255;
  int b = 255;
  unsigned int n = r/8 * 2048 + g/4 * 32 + b/8;
  Serial.println(n,HEX);
}
void loop() {}" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">// Convert 24-bit colours to 16-bit colours</span></span>
<span class="line"><span style="color: #768390">// Tony Goodhew 22 Sept 2020</span></span>
<span class="line"><span style="color: #768390">// Tutorial45.com</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  unsigned int n </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r</span><span style="color: #F47067">/</span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g</span><span style="color: #F47067">/</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b</span><span style="color: #F47067">/</span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(n,</span><span style="color: #6CB6FF">HEX</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">() {}</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">The following sketch indicates the colors available by converting an array of 24-bit color values into their 16-bit equivalent and displaying them on the screen with the data. There are not enough pixels on the screen to display all the colors simultaneously, so the last part of the sketch takes out the least significant green bit and displays half the available colors in six ways.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="//  Almost all the colours - several ways
//  AZ-Delivery 2.4&quot; TFT LCD touch shield Demo
//          Shield on Arduino UNO
//  +++ Tony Goodhew 25th September 2020 +++
//  Tutorial45.com

#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_TFTLCD.h&gt;

#define LCD_CS A3     // Chip Select goes to Analog 3
#define LCD_CD A2     // Command/Data goes to Analog 2
#define LCD_WR A1     // LCD Write goes to Analog 1
#define LCD_RD A0     // LCD Read goes to Analog 0
#define LCD_RESET A4  // Can alternately just connect to Arduino's reset pin

#define RED 0xF800
#define YELLOW 0xFFE0
#define BLUE 0x001F
// Create the TFT object with all pin assignments
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// =========== SETUP ================
int title(String s){
    tft.fillScreen(0); // Clears the screen
    tft.setTextSize(3);
    tft.setCursor(60, 200);
    tft.setTextColor(0xC618); // Lt_Grey
    tft.println(&quot;32768 pixels&quot;);
    tft.setCursor(120, 5);
    tft.println(s);   
  }
void setup() {
  Serial.begin(9600); // Useful for debugging
  tft.reset();
  tft.begin(0x9341);  // SDFP5408 - start the display
  tft.setRotation(3); // 320 wide by 240 high - reset button on left
  tft.fillScreen(0); // Clears the screen
  tft.setCursor(30, 50);
  tft.setTextColor(RED);
  tft.setTextSize(3);
  tft.println(&quot;AZ-Delivery&quot;);
  tft.setTextColor(YELLOW);
  tft.setCursor(30, 90);
  tft.println(&quot;16-bit colours&quot;);
  tft.setCursor(30, 120);
  tft.println(&quot;from&quot;);
  tft.setCursor(30, 150);
  tft.println(&quot;24-bit colours&quot;);
  tft.setTextColor(BLUE);
  tft.setCursor(30, 185);
  tft.setTextSize(2);
  tft.println(&quot;Tutorial45.com&quot;);
  delay(4000);
  // A few interesting 24-bit colours - some dim - some bright!
  unsigned long c1[] = {
        0x000000,0xFFFFFF,0x333333,0x666666,0x999999,0xCCCCCC,0xCCCC99,0x9999CC,0x666699,
        0x660000,0x663300,0x996633,0x003300,0x003333,0x003399,0x000066,0x330066,0x660066,
        0x990000,0x993300,0xCC9900,0x006600,0x336666,0x0033FF,0x000099,0x660099,0x990066,
        0xCC0000,0xCC3300,0xFFCC00,0x009900,0x006666,0x0066FF,0x0000CC,0x663399,0xCC0099,
        0xFF0000,0xFF3300,0xFFFF00,0x00CC00,0x009999,0x0099FF,0x0000FF,0x9900CC,0xFF0099,
        0xCC3333,0xFF6600,0xFFFF33,0x00FF00,0x00CCCC,0x00CCFF,0x3366FF,0x9933FF,0xFF00FF,
        0xFF6666,0xFF6633,0xFFFF66,0x66FF66,0x66CCCC,0x00FFFF,0x3399FF,0x9966FF,0xFF66FF,
        0xFF9999,0xFF9966,0xFFFF99,0x99FF99,0x66FFCC,0x99FFFF,0x66CCFF,0x9999FF,0xFF99FF,
        0xFFCCCC,0xFFCC99,0xFFFFCC,0xCCFFCC,0x99FFCC,0xCCFFFF,0x99CCFF,0xCCCCFF,0xFFCCFF};
  unsigned int c2[80];      
  
  int l = 81;
  tft.fillScreen(0); // Clears the screen
  for (int i = 0; i &lt; l; i++){
    int r = c1[i] &gt;&gt; 16;              // Get red 24-bit component - 0 to 255  
    int g = (c1[i] &amp; 0x00ff00) &gt;&gt; 8;  // Get green
    int b = (c1[i] &amp; 0x0000ff);       // Get blue
    unsigned long col2 = r/8 * 2048 + g/4 * 32 + b/8;  // Create 16-bit value
    // int division removes least significant bits 
    // multiplication shifts bits left 
    tft.fillScreen(0);
    tft.fillRect(40,20,240,120,col2);
    tft.setTextSize(3);
    tft.setCursor(37, 145);
    tft.setTextColor(0xC618); // Lt_Grey
    tft.print(&quot;24-bit: &quot;);   
    tft.println(c1[i] &amp; 0xFFFFFF,HEX);
    tft.println(&quot; RGB: &quot;+String(r) +&quot; &quot;+ String(g) +&quot; &quot;+String(b));
    int col3 = col2 &amp; 0xFFFF;
    c2[i] = col3;
    String q =String(c2[i], HEX);
    q.toUpperCase();
//    String s = String(&quot;   16-bit: &quot;+String(c2[i], HEX));
    String s = String(&quot;   16-bit: &quot;+q);
    tft.println(s);
    delay(800);
  }
  int x = 0;
  int y = 0;
  unsigned int c = 0;
  String s = &quot;R G B&quot;;
  title(s); 
  for (int r = 0; r &lt;32; r = r + 1){
    for (int g = 0; g &lt; 64; g=g+2){
      for (int b = 0; b &lt; 32; b = b + 1){
        unsigned int c = r * 2048 + g * 32 + b;  // Create 16-bit value
        tft.drawPixel(x +30, y+45, c);
        x = x + 1;
          if (x &gt; 255){
            x = 0;
            y = y + 1; } } } }
  delay(1000);
  s = &quot;B G R&quot;;
  title(s);
  x = 0; y = 0;    
  for (int b = 0; b &lt;32; b = b + 1){
    for (int g = 0; g &lt; 64; g = g + 2){
      for (int r = 0; r &lt; 32; r = r + 1){
        unsigned int c = r * 2048 + g * 32 + b;  // Create 16-bit value
        tft.drawPixel(x +30, y+45, c);
        x = x + 1;
          if (x &gt; 255){
            x = 0;
            y = y + 1; } } } }
  delay(1000);
  s = &quot;G B R&quot;;
  title(s);
  x = 0; y = 0; 
  for (int g = 0; g &lt; 64; g = g + 2){    
    for (int b = 0; b &lt;32; b = b + 1){ 
      for (int r = 0; r &lt; 32; r = r + 1){
        unsigned int c = r * 2048 + g * 32 + b;  // Create 16-bit value
        tft.drawPixel(x +30, y+45, c);
        x = x + 1;
          if (x &gt; 255){
            x = 0;
            y = y + 1; } } } }
  delay(1000);
  s = &quot;R B G&quot;;
  title(s);
  x = 0; y = 0;
  for (int r = 0; r &lt; 32; r = r + 1){    
    for (int b = 0; b &lt;32; b = b + 1){ 
      for (int g = 0; g &lt; 64; g = g + 2){
        unsigned int c = r * 2048 + g * 32 + b;  // Create 16-bit value
        tft.drawPixel(x +30, y+45, c);
        x = x + 1;
          if (x &gt; 255){
            x = 0;
            y = y + 1; } } } }
  delay(1000);
  s = &quot;B R G&quot;;
  title(s);
  x = 0; y = 0; 
  for (int b = 0; b &lt;32; b = b + 1){
     for (int r = 0; r &lt; 32; r = r + 1){
        for (int g = 0; g &lt; 64; g = g + 2){ 
        unsigned int c = r * 2048 + g * 32 + b;  // Create 16-bit value
        tft.drawPixel(x +30, y+45, c);
        x = x + 1;
          if (x &gt; 255){
            x = 0;
            y = y + 1; } } } }
  delay(1000);
  s = &quot;G R B&quot;;
  title(s);
  x = 0; y = 0;
  for (int g = 0; g &lt; 64; g = g + 2){
    for (int r = 0; r &lt; 32; r = r + 1){ 
      for (int b = 0; b &lt;32; b = b + 1){
        unsigned int c = r * 2048 + g * 32 + b;  // Create 16-bit value
        tft.drawPixel(x +30, y+45, c);
        x = x + 1;
          if (x &gt; 255){
            x = 0;
            y = y + 1; } } } }
}   
void loop() {} //-- LOOP NOT NEEDED --" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">//  Almost all the colours - several ways</span></span>
<span class="line"><span style="color: #768390">//  AZ-Delivery 2.4&quot; TFT LCD touch shield Demo</span></span>
<span class="line"><span style="color: #768390">//          Shield on Arduino UNO</span></span>
<span class="line"><span style="color: #768390">//  +++ Tony Goodhew 25th September 2020 +++</span></span>
<span class="line"><span style="color: #768390">//  Tutorial45.com</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_GFX.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_TFTLCD.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A3</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Chip Select goes to Analog 3</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A2</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Command/Data goes to Analog 2</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A1</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Write goes to Analog 1</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A0</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Read goes to Analog 0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A4</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// Can alternately just connect to Arduino&#39;s reset pin</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF800</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFE0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x001F</span></span>
<span class="line"><span style="color: #768390">// Create the TFT object with all pin assignments</span></span>
<span class="line"><span style="color: #ADBAC7">Adafruit_TFTLCD </span><span style="color: #DCBDFB">tft</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// =========== SETUP ================</span></span>
<span class="line"><span style="color: #ADBAC7">int </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(String s){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Clears the screen</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0xC618</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Lt_Grey</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;32768 pixels&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(s);   </span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Useful for debugging</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">reset</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0x9341</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// SDFP5408 - start the display</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setRotation</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// 320 wide by 240 high - reset button on left</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Clears the screen</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">50</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;AZ-Delivery&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">90</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;16-bit colours&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;from&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">150</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;24-bit colours&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">185</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Tutorial45.com&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">4000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// A few interesting 24-bit colours - some dim - some bright!</span></span>
<span class="line"><span style="color: #ADBAC7">  unsigned long c1[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0x000000</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFFFFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x333333</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x666666</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x999999</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCCCCCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCCCC99</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x9999CC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x666699</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0x660000</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x663300</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x996633</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x003300</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x003333</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x003399</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x000066</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x330066</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x660066</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0x990000</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x993300</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCC9900</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x006600</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x336666</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x0033FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x000099</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x660099</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x990066</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0xCC0000</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCC3300</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFCC00</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x009900</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x006666</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x0066FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x0000CC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x663399</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCC0099</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0xFF0000</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF3300</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFFF00</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x00CC00</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x009999</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x0099FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x0000FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x9900CC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF0099</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0xCC3333</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF6600</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFFF33</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x00FF00</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x00CCCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x00CCFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x3366FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x9933FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF00FF</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0xFF6666</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF6633</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFFF66</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x66FF66</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x66CCCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x00FFFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x3399FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x9966FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF66FF</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0xFF9999</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF9966</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFFF99</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x99FF99</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x66FFCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x99FFFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x66CCFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x9999FF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFF99FF</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0xFFCCCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFCC99</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFFFCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCCFFCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x99FFCC</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCCFFFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0x99CCFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xCCCCFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0xFFCCFF</span><span style="color: #ADBAC7">};</span></span>
<span class="line"><span style="color: #ADBAC7">  unsigned int c2[</span><span style="color: #6CB6FF">80</span><span style="color: #ADBAC7">];      </span></span>
<span class="line"><span style="color: #ADBAC7">  </span></span>
<span class="line"><span style="color: #ADBAC7">  int l </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">81</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Clears the screen</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int i </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; i </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> l; i</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> c1[i] </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">16</span><span style="color: #ADBAC7">;              </span><span style="color: #768390">// Get red 24-bit component - 0 to 255  </span></span>
<span class="line"><span style="color: #ADBAC7">    int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> (c1[i] </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x00ff00</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7">;  </span><span style="color: #768390">// Get green</span></span>
<span class="line"><span style="color: #ADBAC7">    int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> (c1[i] </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x0000ff</span><span style="color: #ADBAC7">);       </span><span style="color: #768390">// Get blue</span></span>
<span class="line"><span style="color: #ADBAC7">    unsigned long col2 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r</span><span style="color: #F47067">/</span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g</span><span style="color: #F47067">/</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b</span><span style="color: #F47067">/</span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7">;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// int division removes least significant bits </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// multiplication shifts bits left </span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">120</span><span style="color: #ADBAC7">,col2);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">37</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">145</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0xC618</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Lt_Grey</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;24-bit: &quot;</span><span style="color: #ADBAC7">);   </span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(c1[i] </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFFFFF</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">HEX</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot; RGB: &quot;</span><span style="color: #F47067">+</span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(r) </span><span style="color: #F47067">+</span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(g) </span><span style="color: #F47067">+</span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #F47067">+</span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(b));</span></span>
<span class="line"><span style="color: #ADBAC7">    int col3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> col2 </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFFF</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    c2[i] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> col3;</span></span>
<span class="line"><span style="color: #ADBAC7">    String q </span><span style="color: #F47067">=</span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(c2[i], </span><span style="color: #6CB6FF">HEX</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    q.</span><span style="color: #DCBDFB">toUpperCase</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #768390">//    String s = String(&quot;   16-bit: &quot;+String(c2[i], HEX));</span></span>
<span class="line"><span style="color: #ADBAC7">    String s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;   16-bit: &quot;</span><span style="color: #F47067">+</span><span style="color: #ADBAC7">q);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(s);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">800</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  int x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  String s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;R G B&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(s); </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">; g</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">g</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> b </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">        unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">, c);</span></span>
<span class="line"><span style="color: #ADBAC7">        x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">          </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (x </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">            x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">            y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; } } } }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;B G R&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(s);</span></span>
<span class="line"><span style="color: #ADBAC7">  x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;    </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> b </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">        unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">, c);</span></span>
<span class="line"><span style="color: #ADBAC7">        x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">          </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (x </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">            x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">            y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; } } } }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;G B R&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(s);</span></span>
<span class="line"><span style="color: #ADBAC7">  x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){    </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> b </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){ </span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">        unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">, c);</span></span>
<span class="line"><span style="color: #ADBAC7">        x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">          </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (x </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">            x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">            y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; } } } }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;R B G&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(s);</span></span>
<span class="line"><span style="color: #ADBAC7">  x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){    </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> b </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){ </span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">        unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">, c);</span></span>
<span class="line"><span style="color: #ADBAC7">        x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">          </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (x </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">            x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">            y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; } } } }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;B R G&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(s);</span></span>
<span class="line"><span style="color: #ADBAC7">  x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> b </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">     </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){ </span></span>
<span class="line"><span style="color: #ADBAC7">        unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">, c);</span></span>
<span class="line"><span style="color: #ADBAC7">        x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">          </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (x </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">            x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">            y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; } } } }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">delay</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;G R B&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">title</span><span style="color: #ADBAC7">(s);</span></span>
<span class="line"><span style="color: #ADBAC7">  x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">; g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){ </span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7">; b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> b </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">        unsigned int c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> r </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> g </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> b;  </span><span style="color: #768390">// Create 16-bit value</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">drawPixel</span><span style="color: #ADBAC7">(x </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">, y</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">, c);</span></span>
<span class="line"><span style="color: #ADBAC7">        x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">          </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (x </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">255</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">            x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">            y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> y </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; } } } }</span></span>
<span class="line"><span style="color: #ADBAC7">}   </span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">() {} </span><span style="color: #768390">//-- LOOP NOT NEEDED --</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="479" height="410" src="https://tutorial45.com/wp-content/uploads/2020/10/touch-screen-arduino.jpg" alt="" class="wp-image-10476" style="width:479px;height:auto" srcset="https://tutorial45.com/wp-content/uploads/2020/10/touch-screen-arduino.jpg 479w, https://tutorial45.com/wp-content/uploads/2020/10/touch-screen-arduino-300x257.jpg 300w" sizes="(max-width: 479px) 100vw, 479px" /></figure>
</div>


<h2 class="wp-block-heading">Using the SD card reader</h2>



<p class="wp-block-paragraph">Looking at the bottom of the board there are 4 pins used for communication with the SD card reader:</p>



<p class="wp-block-paragraph">SD_SS pin 10-SS = Chip Select<br>SD_DI pin 11- MOSI<br>SD_DO pin 12-MISO<br>SD_SCK pin 13-CLOCK</p>



<p class="wp-block-paragraph">This is a standard SD card reader and uses the SPI pins on the UNO and pin 10 as the Chip Select.</p>



<p class="wp-block-paragraph">The Arduino.cc site lists the following SPI pins on their different boards</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Arduino / Genuino Board</strong></td><td><strong>MOSI</strong></td><td><strong>MISO</strong></td><td><strong>SCK</strong></td><td><strong>SS (slave)</strong></td><td><strong>SS (master)</strong></td><td><strong>Level</strong></td></tr><tr><td><strong>Uno or Duemilanove</strong></td><td>11 or ICSP-4</td><td>12 or ICSP-1</td><td>13 or ICSP-3</td><td>10</td><td>&#8211;</td><td>5V</td></tr><tr><td><strong>Mega1280 or Mega2560</strong></td><td>51 or ICSP-4</td><td>50 or ICSP-1</td><td>52 or ICSP-3</td><td>53</td><td>&#8211;</td><td>5V</td></tr><tr><td><strong>Leonardo</strong></td><td>ICSP-4</td><td>ICSP-1</td><td>ICSP-3</td><td>&#8211;</td><td>&#8211;</td><td>5V</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">If you need to use the SD card with a MEGA you will need to run the board via jumper leads.</p>



<p class="wp-block-paragraph">The SD card reader library is included with the basic setup, so we do not need to load a fresh library. The examples cover the simple tasks of creating, writing to, reading from and deleting files at a very basic level, all with strings.</p>



<p class="wp-block-paragraph">I used a 16GB SD-HC class 4 card. It is easy to insert into the reader with a gentle push. Push in again to extract if necessary.</p>



<p class="wp-block-paragraph">To check that everything is in order you can run the “CardInfo” sketch from the Examples tab of the File muenu. (File =&gt;&gt; Examples =&gt;&gt; SD =&gt;&gt; CardInfo.)&nbsp; Make sure you set:</p>



<p class="wp-block-paragraph">const int chipSelect = 10;</p>



<p class="wp-block-paragraph">on the line before the setup routine. I got the following with my card, which I had been using earlier.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="516" height="361" src="https://tutorial45.com/wp-content/uploads/2020/10/cardinfo.jpg" alt="" class="wp-image-10477" srcset="https://tutorial45.com/wp-content/uploads/2020/10/cardinfo.jpg 516w, https://tutorial45.com/wp-content/uploads/2020/10/cardinfo-300x210.jpg 300w" sizes="(max-width: 516px) 100vw, 516px" /></figure>



<p class="wp-block-paragraph">At this point it is worth running the other example sketches to get a feel for how the card reader works.&nbsp;</p>



<p class="wp-block-paragraph">You may have noticed that:</p>



<ul class="wp-block-list">
<li>This is a very basic serial file device.</li>



<li>You can only have one file open at a time.</li>



<li>You write strings to the file (so numbers have to be converted to strings before they are saved.)</li>



<li>You can make up a record of several strings which are in turn made up of characters.</li>



<li>You concatenate the sub-strings to make the record string using a comma as a delimiter.</li>



<li>Each line in the file is a record which terminates with “\n”.</li>



<li>If you write to an existing file the new data is appended at the end.</li>



<li>In the examples the chip select pin is 4. We have to use pin 10 when the shield is plugged into an UNO.</li>
</ul>



<p class="wp-block-paragraph">An obvious use for the SD reader is to log readings from sensors and display the results on the TFT display. Unfortunately,&nbsp; the shield covers and uses most of the pins. The solution is to connect just the SD reader and power pins with jump leads which leaves plenty of pins to collect data from sensors.&nbsp;&nbsp;</p>



<p class="wp-block-paragraph">Most Arduino users seldom use string manipulation. The documentation and a few simple examples of how to use strings are well scattered over the Web and difficult to find. The first sketch demonstrates how to create a file of 5 records/lines, each made up from an integer, a string, and a floating-point variable. The file is called <strong>datalog6.txt</strong>.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="// Create a log file sketch
// Write demo log file: 'datalog6.txt' with 3 fields per
//      record: Int, String and Float
// The SD_Read_File sketch can process it.
// Tony Goodhew 21 Sept 2020
// SD reader on TFT shield – Output to Serial Monitor
// Tutorial45.com
#include &lt;SPI.h&gt;
#include &lt;SD.h&gt;
const int chipSelect = 10;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);{}
  Serial.print(&quot;Initializing SD card...&quot;);
// see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println(&quot;Card failed, or not present&quot;);
    // Halt
    while (1);
  }
  Serial.println(&quot;card initialized.&quot;);
  File dataFile = SD.open(&quot;datalog6.txt&quot;, FILE_WRITE);
  // Set up test data in 3 arrays
  int i[] = {1, 2222, 3, -4, 5};
  String s[] = {&quot;Tony&quot;, &quot;Fred&quot;, &quot;Anne&quot;, &quot;Mags&quot;, &quot;William&quot;};
  float f[] = {3.14, 2.2, 3.3333, 10.66, -5.5};
  String j = &quot;&quot;;  // record string
  Serial.println(&quot;Writing datalog6.txt&quot;);
  // Loop for 5 data records
  for (int p=0; p &lt; 5; p++){
    // Pack the data up into a string, j
    // Build long string with 3 data items as strings
    //    separated with commas
    j = String(i[p]) + &quot;,&quot; + s[p]+ &quot;,&quot; + String(f[p]); // One record
    // Display the long string
    Serial.println(j);
    // Save j to SD Card
    // if the file is available, write to it:
    if (dataFile) {
      dataFile.println(j);  // Write j to the file
    }
    // if the file isn't open, pop up an error:
    else {
    Serial.println(&quot;error opening datalog6.txt&quot;);
    }
  }
  dataFile.close(); 
  Serial.println(&quot;\nFile datalog6.txt written - FINISHED!\n&quot;);  
}
void loop() {}" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">// Create a log file sketch</span></span>
<span class="line"><span style="color: #768390">// Write demo log file: &#39;datalog6.txt&#39; with 3 fields per</span></span>
<span class="line"><span style="color: #768390">//      record: Int, String and Float</span></span>
<span class="line"><span style="color: #768390">// The SD_Read_File sketch can process it.</span></span>
<span class="line"><span style="color: #768390">// Tony Goodhew 21 Sept 2020</span></span>
<span class="line"><span style="color: #768390">// SD reader on TFT shield – Output to Serial Monitor</span></span>
<span class="line"><span style="color: #768390">// Tutorial45.com</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">SPI</span><span style="color: #ADBAC7">.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">SD</span><span style="color: #ADBAC7">.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7"> chipSelect </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Open serial communications and wait for port to open:</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">);{}</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Initializing SD card...&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #768390">// see if the card is present and can be initialized:</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (</span><span style="color: #F47067">!</span><span style="color: #6CB6FF">SD</span><span style="color: #ADBAC7">.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(chipSelect)) {</span></span>
<span class="line"><span style="color: #ADBAC7">    Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Card failed, or not present&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Halt</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">while</span><span style="color: #ADBAC7"> (</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;card initialized.&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  File dataFile </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">SD</span><span style="color: #ADBAC7">.</span><span style="color: #DCBDFB">open</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;datalog6.txt&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">FILE_WRITE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Set up test data in 3 arrays</span></span>
<span class="line"><span style="color: #ADBAC7">  int i[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">2222</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">, -</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">};</span></span>
<span class="line"><span style="color: #ADBAC7">  String s[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #96D0FF">&quot;Tony&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Fred&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Anne&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Mags&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;William&quot;</span><span style="color: #ADBAC7">};</span></span>
<span class="line"><span style="color: #ADBAC7">  float f[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #6CB6FF">3.14</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">2.2</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">3.3333</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10.66</span><span style="color: #ADBAC7">, -</span><span style="color: #6CB6FF">5.5</span><span style="color: #ADBAC7">};</span></span>
<span class="line"><span style="color: #ADBAC7">  String j </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">;  </span><span style="color: #768390">// record string</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Writing datalog6.txt&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Loop for 5 data records</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int p</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; p </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">; p</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Pack the data up into a string, j</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Build long string with 3 data items as strings</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">//    separated with commas</span></span>
<span class="line"><span style="color: #ADBAC7">    j </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(i[p]) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;,&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> s[p]</span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;,&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(f[p]); </span><span style="color: #768390">// One record</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Display the long string</span></span>
<span class="line"><span style="color: #ADBAC7">    Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(j);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Save j to SD Card</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// if the file is available, write to it:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (dataFile) {</span></span>
<span class="line"><span style="color: #ADBAC7">      dataFile.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(j);  </span><span style="color: #768390">// Write j to the file</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// if the file isn&#39;t open, pop up an error:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;error opening datalog6.txt&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  dataFile.</span><span style="color: #DCBDFB">close</span><span style="color: #ADBAC7">(); </span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">File datalog6.txt written - FINISHED!</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">);  </span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">() {}</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">The second sketch reads the data we have saved in the <strong>datalog6.txt</strong> file. It splits each line/record into the 3 strings and then converts one to an Integer and the another to Floating Point. Just to prove that they are now stored as numbers it multiplies them together and displays the result.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="// Read the data back from a log file: 'datalog6.txt'
// Tony Goodhew 21 Sept 2020
// SD reader on TFT shield
// Tutorial45.com

#include &lt;SPI.h&gt;
#include &lt;SD.h&gt;

const int chipSelect = 10;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.print(&quot;Initializing SD card...&quot;);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println(&quot;Card failed, or not present&quot;);
    // don't do anything more:
    while (1);
  }
  Serial.println(&quot;card initialized.&quot;);

  // Open the file
  File dataFile = SD.open(&quot;datalog6.txt&quot;);
  Serial.println(&quot;Reading datalog6.txt&quot;);
  String j = &quot;&quot;; // Holds a line from the data file (3 fields = 1 record)
  
  if (dataFile) {
    while (dataFile.available()) {        // Not reached the End Of File     
      j = dataFile.readStringUntil('\n'); // Get single line from file
      Serial.println(&quot;\n&quot;+j);
      int comma1 = j.indexOf(','); 
      int comma2 = j.indexOf(',', comma1 + 1); 
      Serial.println(&quot;Commas: &quot; + String(comma1) + &quot; &quot;+ String(comma2));
      // Separate back into 3 strings at the commas
      String ii = j.substring(0,comma1);              // integer
      String sname = j.substring(comma1 +1, comma2);  // string
      String ff = j.substring(comma2 +1);             // float
      // Print out the strings
      Serial.println(ii);
      Serial.println(sname);
      Serial.println(ff);
      int iOut = ii.toInt(); // Convert back to integer
      float fOut = ff.toFloat();  // Convert back to Floating Point
      float res = iOut * fOut;    // Calculation with both numbers
      Serial.println(sname +&quot;: &quot; + String(res)+&quot;\n&quot;);  // Output the result
    }
    dataFile.close();
  }
  // if the file isn't open, print up an error message
  else {
    Serial.println(&quot;error opening datalog6.txt&quot;);
  }
}
void loop() {}" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">// Read the data back from a log file: &#39;datalog6.txt&#39;</span></span>
<span class="line"><span style="color: #768390">// Tony Goodhew 21 Sept 2020</span></span>
<span class="line"><span style="color: #768390">// SD reader on TFT shield</span></span>
<span class="line"><span style="color: #768390">// Tutorial45.com</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">SPI</span><span style="color: #ADBAC7">.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">SD</span><span style="color: #ADBAC7">.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7"> chipSelect </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Open serial communications and wait for port to open:</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">while</span><span style="color: #ADBAC7"> (</span><span style="color: #F47067">!</span><span style="color: #ADBAC7">Serial) {</span></span>
<span class="line"><span style="color: #ADBAC7">    ; </span><span style="color: #768390">// wait for serial port to connect. Needed for native USB port only</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Initializing SD card...&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// see if the card is present and can be initialized:</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (</span><span style="color: #F47067">!</span><span style="color: #6CB6FF">SD</span><span style="color: #ADBAC7">.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(chipSelect)) {</span></span>
<span class="line"><span style="color: #ADBAC7">    Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Card failed, or not present&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// don&#39;t do anything more:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">while</span><span style="color: #ADBAC7"> (</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;card initialized.&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Open the file</span></span>
<span class="line"><span style="color: #ADBAC7">  File dataFile </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">SD</span><span style="color: #ADBAC7">.</span><span style="color: #DCBDFB">open</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;datalog6.txt&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Reading datalog6.txt&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  String j </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">; </span><span style="color: #768390">// Holds a line from the data file (3 fields = 1 record)</span></span>
<span class="line"><span style="color: #ADBAC7">  </span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (dataFile) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">while</span><span style="color: #ADBAC7"> (dataFile.</span><span style="color: #DCBDFB">available</span><span style="color: #ADBAC7">()) {        </span><span style="color: #768390">// Not reached the End Of File     </span></span>
<span class="line"><span style="color: #ADBAC7">      j </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> dataFile.</span><span style="color: #DCBDFB">readStringUntil</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&#39;</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Get single line from file</span></span>
<span class="line"><span style="color: #ADBAC7">      Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">+</span><span style="color: #ADBAC7">j);</span></span>
<span class="line"><span style="color: #ADBAC7">      int comma1 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> j.</span><span style="color: #DCBDFB">indexOf</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;,&#39;</span><span style="color: #ADBAC7">); </span></span>
<span class="line"><span style="color: #ADBAC7">      int comma2 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> j.</span><span style="color: #DCBDFB">indexOf</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;,&#39;</span><span style="color: #ADBAC7">, comma1 </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">); </span></span>
<span class="line"><span style="color: #ADBAC7">      Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Commas: &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(comma1) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(comma2));</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #768390">// Separate back into 3 strings at the commas</span></span>
<span class="line"><span style="color: #ADBAC7">      String ii </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> j.</span><span style="color: #DCBDFB">substring</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,comma1);              </span><span style="color: #768390">// integer</span></span>
<span class="line"><span style="color: #ADBAC7">      String sname </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> j.</span><span style="color: #DCBDFB">substring</span><span style="color: #ADBAC7">(comma1 </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">, comma2);  </span><span style="color: #768390">// string</span></span>
<span class="line"><span style="color: #ADBAC7">      String ff </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> j.</span><span style="color: #DCBDFB">substring</span><span style="color: #ADBAC7">(comma2 </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">);             </span><span style="color: #768390">// float</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #768390">// Print out the strings</span></span>
<span class="line"><span style="color: #ADBAC7">      Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(ii);</span></span>
<span class="line"><span style="color: #ADBAC7">      Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(sname);</span></span>
<span class="line"><span style="color: #ADBAC7">      Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(ff);</span></span>
<span class="line"><span style="color: #ADBAC7">      int iOut </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ii.</span><span style="color: #DCBDFB">toInt</span><span style="color: #ADBAC7">(); </span><span style="color: #768390">// Convert back to integer</span></span>
<span class="line"><span style="color: #ADBAC7">      float fOut </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ff.</span><span style="color: #DCBDFB">toFloat</span><span style="color: #ADBAC7">();  </span><span style="color: #768390">// Convert back to Floating Point</span></span>
<span class="line"><span style="color: #ADBAC7">      float res </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> iOut </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> fOut;    </span><span style="color: #768390">// Calculation with both numbers</span></span>
<span class="line"><span style="color: #ADBAC7">      Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(sname </span><span style="color: #F47067">+</span><span style="color: #96D0FF">&quot;: &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(res)</span><span style="color: #F47067">+</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// Output the result</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">    dataFile.</span><span style="color: #DCBDFB">close</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// if the file isn&#39;t open, print up an error message</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    Serial.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;error opening datalog6.txt&quot;</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">() {}</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading">Using the Touch Layer</h2>



<p class="wp-block-paragraph">This is the part that often causes the most trouble with many owners giving up at this point. It may be because there are several different configurations of the pins used to connect to the touch layers of the screen on the many varied breakout boards and shields using this display. In this case four of the pins are used, at different times, to control both the graphics or the touch elements of the screen.</p>



<p class="wp-block-paragraph"><strong>How does a touch screen sense position?</strong></p>



<p class="wp-block-paragraph">This is a resistive touch screen, rather than a capacitive one. Above the graphics, layers are two transparent resistive layers held apart by tiny dimples. One is connected at the top and bottom and the other at the sides. A potential difference is applied across them and when the stylus or a finger presses on the screen an electrical connection is made between the resistive layers. </p>



<p class="wp-block-paragraph">The Analog pins are used to measure the voltages at that point on the two resistive layers, one at a time, in the same manner as we read the voltage from the wiper of a potentiometer – a potential divider. Using these values, it is possible to calculate, quite accurately, the coordinates of the point on the screen where the pressure has been applied. Calibration is often needed to improve accuracy. Adafruit suggests reading the resistance across the X plate (XP = D8 and XM = A2). On my board, I got 341 Ohms. Use this value as SENSITIVITY.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="// Simple Drawing Script for AZ-Delivery TFT Touch 240x320 Shield
// Tony Goodhew 30 Sept 2020
// Modified from Adafruit examples for a similar shield
// Tutorial45.com
// Adafruit GFX Libraries
#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_TFTLCD.h&gt;
#include &lt;TouchScreen.h&gt;

#define LCD_CS A3     // Chip Select goes to Analog 3
#define LCD_CD A2     // Command/Data goes to Analog 2
#define LCD_WR A1     // LCD Write goes to Analog 1
#define LCD_RD A0     // LCD Read goes to Analog 0
#define LCD_RESET A4  // Can alternately just connect to Arduino's reset pin

// 16-bit colour values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
unsigned int c[] = {BLACK,RED,GREEN,BLUE,CYAN,MAGENTA,YELLOW,WHITE};
int cc = c[1];

// Create the TFT (Graphics) object - named pins
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// Set up the touch screen element of the TFT screen
#define YP A3  // must be an analog pin, use &quot;An&quot; notation!
#define XM A2  // must be an analog pin, use &quot;An&quot; notation!
#define YM 9   // can be a digital pin
#define XP 8   // can be a digital pin
#define SENSITIVITY 341                   // Was 300 = Resistance A2 to D8                                                                         
#define MINPRESSURE 10
#define MAXPRESSURE 1000
#define TS_MINX  150
#define TS_MINY  120
#define TS_MAXX  920
#define TS_MAXY  940
#define MINPRESSURE 10
#define MAXPRESSURE 1000
// Create Touch Screen object
TouchScreen ts = TouchScreen(XP, YP, XM, YM, SENSITIVITY);

void palette(){       // Create colour 'buttons' at top of screen
   int w = 30;
   int h = 40;
   tft.fillRect(0, 0, w, h, BLACK);
   tft.fillRect(w, 0, w, h, RED);
   tft.fillRect(w*2, 0, w, h, GREEN);
   tft.fillRect(w*3, 0, w, h, BLUE);
   tft.fillRect(w*4, 0, w, h, CYAN);
   tft.fillRect(w*5, 0, w, h, MAGENTA);
   tft.fillRect(w*6, 0, w, h, YELLOW);
   tft.fillRect(w*7, 0, w, h, WHITE); 
}
//---------SETUP--------------------
void setup() {
  Serial.begin(9600);
  tft.reset();
  tft.begin(0x9341);  // SDFP5408
  tft.fillRect(0,0, 240,320, BLACK);  // Drawing area
  palette();  // Drawing colour buttons
}
//---------Main Loop------------
void loop(){
  TSPoint p = ts.getPoint(); // Read the Touch Screen
  // Shared pins - fix direction
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);

  // Check for pressure on screen
  if (p.z &gt; MINPRESSURE &amp;&amp; p.z &lt; MAXPRESSURE) {
/*  // Debugging     
    Serial.print(&quot;X = &quot;); Serial.print(p.x);
    Serial.print(&quot;\tY = &quot;); Serial.print(p.y);
    Serial.print(&quot;\tPressure = &quot;); Serial.println(p.z);
*/      
    // Scale Touch values to fit TFT screen 
    // Adjust final number to get drawn dot under the stylus point (fudge factors!)
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0) -10;
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0)-14; 
    
/*  // Debugging   
    Serial.print(&quot;(&quot;); Serial.print(p.x);
    Serial.print(&quot;, &quot;); Serial.print(p.y);
    Serial.println(&quot;)&quot;);
*/    
    if (p.y &lt; 40){                              // In the palette area?
      if (p.x &lt;30){                             // Black to clear drawing area
        tft.fillRect(0, 40, 240,299, BLACK);}
      else{                                     // Change colour
        cc = c[p.x / 30];
      }
    }
    else{
      tft.fillCircle(p.x, p.y, 2, cc);         // Draw dot at stylus point
    }
  }
}" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">// Simple Drawing Script for AZ-Delivery TFT Touch 240x320 Shield</span></span>
<span class="line"><span style="color: #768390">// Tony Goodhew 30 Sept 2020</span></span>
<span class="line"><span style="color: #768390">// Modified from Adafruit examples for a similar shield</span></span>
<span class="line"><span style="color: #768390">// Tutorial45.com</span></span>
<span class="line"><span style="color: #768390">// Adafruit GFX Libraries</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_GFX.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_TFTLCD.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">TouchScreen.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A3</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Chip Select goes to Analog 3</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A2</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Command/Data goes to Analog 2</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A1</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Write goes to Analog 1</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A0</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Read goes to Analog 0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A4</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// Can alternately just connect to Arduino&#39;s reset pin</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// 16-bit colour values:</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x0000</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x001F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF800</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x07E0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">CYAN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x07FF</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAGENTA</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF81F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFE0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFFF</span></span>
<span class="line"><span style="color: #ADBAC7">unsigned int c[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {BLACK,RED,GREEN,BLUE,CYAN,MAGENTA,YELLOW,WHITE};</span></span>
<span class="line"><span style="color: #ADBAC7">int cc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> c[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">];</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Create the TFT (Graphics) object - named pins</span></span>
<span class="line"><span style="color: #ADBAC7">Adafruit_TFTLCD </span><span style="color: #DCBDFB">tft</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Set up the touch screen element of the TFT screen</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YP</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A3</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// must be an analog pin, use &quot;An&quot; notation!</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">XM</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A2</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// must be an analog pin, use &quot;An&quot; notation!</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YM</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">   </span><span style="color: #768390">// can be a digital pin</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">XP</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7">   </span><span style="color: #768390">// can be a digital pin</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">SENSITIVITY</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">341</span><span style="color: #ADBAC7">                   </span><span style="color: #768390">// Was 300 = Resistance A2 to D8                                                                         </span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MINPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAXPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MINX</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">150</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MINY</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">120</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MAXX</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">920</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MAXY</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">940</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MINPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAXPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span>
<span class="line"><span style="color: #768390">// Create Touch Screen object</span></span>
<span class="line"><span style="color: #ADBAC7">TouchScreen ts </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">TouchScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">XP</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">YP</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">XM</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">YM</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">SENSITIVITY</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">palette</span><span style="color: #ADBAC7">(){       </span><span style="color: #768390">// Create colour &#39;buttons&#39; at top of screen</span></span>
<span class="line"><span style="color: #ADBAC7">   int w </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">   int h </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">CYAN</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">MAGENTA</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">YELLOW</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">   tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">*</span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, w, h, </span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7">); </span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">//---------SETUP--------------------</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">reset</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0x9341</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// SDFP5408</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">320</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// Drawing area</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">palette</span><span style="color: #ADBAC7">();  </span><span style="color: #768390">// Drawing colour buttons</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">//---------Main Loop------------</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">(){</span></span>
<span class="line"><span style="color: #ADBAC7">  TSPoint p </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ts.</span><span style="color: #DCBDFB">getPoint</span><span style="color: #ADBAC7">(); </span><span style="color: #768390">// Read the Touch Screen</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Shared pins - fix direction</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">pinMode</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">XM</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">OUTPUT</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">pinMode</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">YP</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">OUTPUT</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Check for pressure on screen</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (p.z </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">MINPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&amp;&amp;</span><span style="color: #ADBAC7"> p.z </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">MAXPRESSURE</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #768390">/*  // Debugging     </span></span>
<span class="line"><span style="color: #768390">    Serial.print(&quot;X = &quot;); Serial.print(p.x);</span></span>
<span class="line"><span style="color: #768390">    Serial.print(&quot;\tY = &quot;); Serial.print(p.y);</span></span>
<span class="line"><span style="color: #768390">    Serial.print(&quot;\tPressure = &quot;); Serial.println(p.z);</span></span>
<span class="line"><span style="color: #768390">*/</span><span style="color: #ADBAC7">      </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Scale Touch values to fit TFT screen </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Adjust final number to get drawn dot under the stylus point (fudge factors!)</span></span>
<span class="line"><span style="color: #ADBAC7">    p.x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">map</span><span style="color: #ADBAC7">(p.x, </span><span style="color: #6CB6FF">TS_MINX</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">TS_MAXX</span><span style="color: #ADBAC7">, tft.</span><span style="color: #DCBDFB">width</span><span style="color: #ADBAC7">(), </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    p.y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">map</span><span style="color: #ADBAC7">(p.y, </span><span style="color: #6CB6FF">TS_MINY</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">TS_MAXY</span><span style="color: #ADBAC7">, tft.</span><span style="color: #DCBDFB">height</span><span style="color: #ADBAC7">(), </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">)</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">14</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">    </span></span>
<span class="line"><span style="color: #768390">/*  // Debugging   </span></span>
<span class="line"><span style="color: #768390">    Serial.print(&quot;(&quot;); Serial.print(p.x);</span></span>
<span class="line"><span style="color: #768390">    Serial.print(&quot;, &quot;); Serial.print(p.y);</span></span>
<span class="line"><span style="color: #768390">    Serial.println(&quot;)&quot;);</span></span>
<span class="line"><span style="color: #768390">*/</span><span style="color: #ADBAC7">    </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (p.y </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">){                              </span><span style="color: #768390">// In the palette area?</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">){                             </span><span style="color: #768390">// Black to clear drawing area</span></span>
<span class="line"><span style="color: #ADBAC7">        tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">40</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">299</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);}</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">{                                     </span><span style="color: #768390">// Change colour</span></span>
<span class="line"><span style="color: #ADBAC7">        cc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> c[p.x </span><span style="color: #F47067">/</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">];</span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">      tft.</span><span style="color: #DCBDFB">fillCircle</span><span style="color: #ADBAC7">(p.x, p.y, </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, cc);         </span><span style="color: #768390">// Draw dot at stylus point</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Try running the sketch to draw on the screen. The BLACK palette ‘button’ clears the screen and the others change the ‘ink’ colour. If the dot drawn is not directly under the stylus you can adjust the ‘fudge factors’ in the scaling section. </p>



<p class="wp-block-paragraph"><strong>16-bit Colour Mixing Project</strong></p>



<p class="wp-block-paragraph">As a final example here is a sketch which shows off the Touch screen with buttons, bar graphs and colours. The buttons allow the user to adjust the RGB mix to display all the possible colours available. If you find one you particularly like it displays the hex value of the 16-bit colour.&nbsp;</p>



<p class="wp-block-paragraph">Gently pressing on the buttons at the bottom with the stylus changes the RGB values within their allowed ranges. The bars move to show the fraction of maximum possible for each of the red, green and blue values.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="292" height="379" src="https://tutorial45.com/wp-content/uploads/2020/10/Project_Final.jpg" alt="" class="wp-image-10478" srcset="https://tutorial45.com/wp-content/uploads/2020/10/Project_Final.jpg 292w, https://tutorial45.com/wp-content/uploads/2020/10/Project_Final-231x300.jpg 231w" sizes="(max-width: 292px) 100vw, 292px" /></figure>
</div>


<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="// Project Sketch for AZ-Delivery TFT Touch 240x320 Shield
// Tony Goodhew 2 October 2020
// Tutorial45.com
// Adafruit GFX Libraries
#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_TFTLCD.h&gt;
#include &lt;TouchScreen.h&gt;

#define LCD_CS A3     // Chip Select goes to Analog 3
#define LCD_CD A2     // Command/Data goes to Analog 2
#define LCD_WR A1     // LCD Write goes to Analog 1
#define LCD_RD A0     // LCD Read goes to Analog 0
#define LCD_RESET A4  // Can alternately just connect to Arduino's reset pin

// 16-bit colour values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define WHITE 0xFFFF

// Create the TFT (Graphics) object - named pins
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// Set up the touch screen element of the TFT screen
#define YP A3  // must be an analog pin, use &quot;An&quot; notation!
#define XM A2  // must be an analog pin, use &quot;An&quot; notation!
#define YM 9   // can be a digital pin
#define XP 8   // can be a digital pin
#define SENSITIVITY 341                   // Was 300 = Resistance A2 to D8                                                                         
#define MINPRESSURE 10
#define MAXPRESSURE 1000
#define TS_MINX  150
#define TS_MINY  120
#define TS_MAXX  920
#define TS_MAXY  940
#define MINPRESSURE 10
#define MAXPRESSURE 1000
// Create Touch Screen object
TouchScreen ts = TouchScreen(XP, YP, XM, YM, SENSITIVITY);

int left[] ={5,45,85,125,165,205};    // left edge of buttons
int right[]={35,75,115,155,195,235};  // right edge of buttons
int red = 15;  // Colours set at mid-points
int green = 31;
int blue = 15;
int old_r = 0;
int old_g = 0;
int old_b = 0;

void graph(int xx, int yy, int p, unsigned int col){
  // Draw a bar graph
  tft.fillRect(xx, yy, 200, 20, BLACK);  // Overwrite to background colour
  tft.fillRect(xx, yy, p * 2, 20, col);  // New bar graph
}
  
void palette(){
  // Create 'buttons' near bottom of screen
  int w = 30;
  int h = 30;
  int y = 280;
  for (int i=0; i&lt;6;i++){
    unsigned int bc = GREEN;
    if (i &lt; 2){bc = RED;}
    if (i &gt; 3){bc = BLUE;}
    tft.fillRect(5 + i *(w+10), y, w, h, bc);
  }
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  for (int i=0; i&lt;6; i = i + 2){
    tft.setCursor(12 + i *(w+10), y +4);
    tft.println(&quot;+&quot;);}
  for (int i=1; i&lt;6; i = i + 2){
      tft.setCursor(12 + i *(w+10), y +4);
      tft.println(&quot;-&quot;);}
}
void show(){
  // Display values and bar graphs
  unsigned int n = red * 2048 + green * 32 + blue;
  tft.fillRect(0, 0, 240, 60, n);
  tft.drawFastVLine(19, 95, 90, 0x7BEF); // Graph axis  
  tft.drawFastVLine(18, 95, 90, 0x7BEF);
  tft.setTextSize(3);
  tft.setTextColor(WHITE);
  if (n &gt; 0xF2BF){tft.setTextColor(BLACK);}  // Black on bright colours
  tft.setCursor(85,20);
  tft.println(n,HEX);
  tft.fillRect(0, 230, 240, 46, BLACK);
  String rS = String(red);
  if (red &lt; 10){rS = &quot; &quot; + rS;}  // Left alignment
  tft.setTextColor(WHITE);
  tft.setCursor(25,230);
  tft.println(rS);
  String gS = String(green);
  if (green &lt; 10){gS = &quot; &quot; + gS;}
  tft.setCursor(105,230);
  tft.println(gS);
  String bS = String(blue);
  if (blue &lt; 10){bS = &quot; &quot; + bS;}
  tft.setCursor(186,230);
  tft.println(bS);
  tft.setTextSize(2);
  int rp = red * 100 / 31;
  int gp = green * 100 / 63;
  int bp = blue * 100 / 31;
  String rz = String(rp) + &quot;%&quot;;
  String gz = String(gp) + &quot;%&quot;;
  String bz = String(bp) + &quot;%&quot;;
  if (rp &lt; 100){rz = &quot; &quot; + rz;}
  if (rp &lt; 10){rz = &quot; &quot; + rz;}
  tft.setCursor(13,260);
  tft.println(rz);
  if (gp &lt; 100){gz = &quot; &quot; + gz;}
  if (gp &lt; 10){gz = &quot; &quot; + gz;}
  tft.setCursor(92,260);
  tft.println(gz);
  if (bp &lt; 100){bz = &quot; &quot; + bz;}
  if (bp &lt; 10){bz = &quot; &quot; + bz;}
  tft.setCursor(174,260);
  tft.println(bz);
  if (old_r != red){                // red value changed?
    graph(20,100,rp,RED);           // Update graph
    old_r = red;
    }
  if (old_g != green){              // green value changed? 
    graph(20,130,gp,GREEN);
    old_g = green;   
  }
  if(old_b != blue){               // blue value change  
    graph(20,160,bp,BLUE);
    old_b = blue;
  }   
}
//---------SETUP------------------
void setup() {
  Serial.begin(9600);
  tft.reset();
  tft.begin(0x9341);  // SDFP5408
  tft.fillRect(0,0, 240,320, BLACK);    // Drawing area
  palette();  // Drawing buttons
  show();  // Display the inital values  
}
//---------Main Loop------------
void loop(){
  TSPoint p = ts.getPoint(); // Read the Touch Screen
  // Shared pins - fix direction
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);

  // Check for pressure on screen
  if (p.z &gt; MINPRESSURE &amp;&amp; p.z &lt; MAXPRESSURE) {
      
    // Scale Touch values to fit TFT screen 
    // Adjust final values to improve accuracy
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0) -10;
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0)-14; 
    
    if ((p.y &gt;= 300) &amp; (p.y &lt;= 330)){               // In the button area?
      if ((p.x &gt;= left[0]) &amp; (p.x &lt;= right[0])){    // Process buttons
        red = red +1;                               //   as necessary
        if (red &gt; 31){red = 31;}
      }
      else if ((p.x &gt;= left[1]) &amp; (p.x &lt;= right[1])){ 
        red = red -1;
        if (red &lt; 0){red = 0;}
      }
      else if ((p.x &gt;= left[2]) &amp; (p.x &lt;= right[2])){ 
        green = green + 1;
        if (green &gt; 63){green = 63;} 
      }
      else if ((p.x &gt;= left[3]) &amp; (p.x &lt;= right[3])){ 
        green = green -1;
        if (green &lt; 0){green = 0;}
      }
      else if ((p.x &gt;= left[4]) &amp; (p.x &lt;= right[4])){ 
        blue = blue + 1;
        if (blue &gt; 31){blue = 31;}
      }
      else if ((p.x &gt;= left[5]) &amp; (p.x &lt;= right[5])){ 
        blue = blue - 1;
        if (blue &lt; 0){blue = 0;}
      }
    }
    // Update Display
    show();
  }
}" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">// Project Sketch for AZ-Delivery TFT Touch 240x320 Shield</span></span>
<span class="line"><span style="color: #768390">// Tony Goodhew 2 October 2020</span></span>
<span class="line"><span style="color: #768390">// Tutorial45.com</span></span>
<span class="line"><span style="color: #768390">// Adafruit GFX Libraries</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_GFX.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">Adafruit_TFTLCD.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">#include </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7">TouchScreen.h</span><span style="color: #F47067">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A3</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Chip Select goes to Analog 3</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A2</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// Command/Data goes to Analog 2</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A1</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Write goes to Analog 1</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A0</span><span style="color: #ADBAC7">     </span><span style="color: #768390">// LCD Read goes to Analog 0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A4</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// Can alternately just connect to Arduino&#39;s reset pin</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// 16-bit colour values:</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x0000</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x001F</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF800</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x07E0</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xFFFF</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Create the TFT (Graphics) object - named pins</span></span>
<span class="line"><span style="color: #ADBAC7">Adafruit_TFTLCD </span><span style="color: #DCBDFB">tft</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">LCD_CS</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_CD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_WR</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RD</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">LCD_RESET</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// Set up the touch screen element of the TFT screen</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YP</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A3</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// must be an analog pin, use &quot;An&quot; notation!</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">XM</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">A2</span><span style="color: #ADBAC7">  </span><span style="color: #768390">// must be an analog pin, use &quot;An&quot; notation!</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">YM</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">   </span><span style="color: #768390">// can be a digital pin</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">XP</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">8</span><span style="color: #ADBAC7">   </span><span style="color: #768390">// can be a digital pin</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">SENSITIVITY</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">341</span><span style="color: #ADBAC7">                   </span><span style="color: #768390">// Was 300 = Resistance A2 to D8                                                                         </span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MINPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAXPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MINX</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">150</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MINY</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">120</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MAXX</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">920</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">TS_MAXY</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">940</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MINPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span>
<span class="line"><span style="color: #ADBAC7">#define </span><span style="color: #6CB6FF">MAXPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span>
<span class="line"><span style="color: #768390">// Create Touch Screen object</span></span>
<span class="line"><span style="color: #ADBAC7">TouchScreen ts </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">TouchScreen</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">XP</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">YP</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">XM</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">YM</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">SENSITIVITY</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">int left[] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">45</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">85</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">125</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">165</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">205</span><span style="color: #ADBAC7">};    </span><span style="color: #768390">// left edge of buttons</span></span>
<span class="line"><span style="color: #ADBAC7">int right[]</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span><span style="color: #6CB6FF">35</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">75</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">115</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">155</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">195</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">235</span><span style="color: #ADBAC7">};  </span><span style="color: #768390">// right edge of buttons</span></span>
<span class="line"><span style="color: #ADBAC7">int red </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">15</span><span style="color: #ADBAC7">;  </span><span style="color: #768390">// Colours set at mid-points</span></span>
<span class="line"><span style="color: #ADBAC7">int green </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">int blue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">15</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">int old_r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">int old_g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">int old_b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">graph</span><span style="color: #ADBAC7">(int xx, int yy, int p, unsigned int col){</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Draw a bar graph</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(xx, yy, </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// Overwrite to background colour</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(xx, yy, p </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">, col);  </span><span style="color: #768390">// New bar graph</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #ADBAC7">  </span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">palette</span><span style="color: #ADBAC7">(){</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Create &#39;buttons&#39; near bottom of screen</span></span>
<span class="line"><span style="color: #ADBAC7">  int w </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int h </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">280</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int i</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; i</span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">;i</span><span style="color: #F47067">++</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    unsigned int bc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (i </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){bc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (i </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">){bc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">*</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">), y, w, h, bc);</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int i</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">; i</span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">; i </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">12</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">*</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">), y </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;+&quot;</span><span style="color: #ADBAC7">);}</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (int i</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">; i</span><span style="color: #F47067">&lt;</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">; i </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">){</span></span>
<span class="line"><span style="color: #ADBAC7">      tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">12</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">*</span><span style="color: #ADBAC7">(w</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">), y </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">      tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;-&quot;</span><span style="color: #ADBAC7">);}</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">show</span><span style="color: #ADBAC7">(){</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Display values and bar graphs</span></span>
<span class="line"><span style="color: #ADBAC7">  unsigned int n </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> red </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2048</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> green </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">32</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> blue;</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">60</span><span style="color: #ADBAC7">, n);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">drawFastVLine</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">19</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">95</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">90</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0x7BEF</span><span style="color: #ADBAC7">); </span><span style="color: #768390">// Graph axis  </span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">drawFastVLine</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">18</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">95</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">90</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0x7BEF</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (n </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0xF2BF</span><span style="color: #ADBAC7">){tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);}  </span><span style="color: #768390">// Black on bright colours</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">85</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(n,</span><span style="color: #6CB6FF">HEX</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">230</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">46</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  String rS </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(red);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (red </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){rS </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> rS;}  </span><span style="color: #768390">// Left alignment</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextColor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">WHITE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">230</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(rS);</span></span>
<span class="line"><span style="color: #ADBAC7">  String gS </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(green);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (green </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){gS </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> gS;}</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">105</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">230</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(gS);</span></span>
<span class="line"><span style="color: #ADBAC7">  String bS </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(blue);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (blue </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){bS </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> bS;}</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">186</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">230</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(bS);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setTextSize</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  int rp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> red </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int gp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> green </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  int bp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> blue </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  String rz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(rp) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;%&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  String gz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(gp) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;%&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  String bz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">String</span><span style="color: #ADBAC7">(bp) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;%&quot;</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (rp </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">){rz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> rz;}</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (rp </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){rz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> rz;}</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">13</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">260</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(rz);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (gp </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">){gz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> gz;}</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (gp </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){gz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> gz;}</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">92</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">260</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(gz);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (bp </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">){bz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> bz;}</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (bp </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">){bz </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot; &quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> bz;}</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">setCursor</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">174</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">260</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">println</span><span style="color: #ADBAC7">(bz);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (old_r </span><span style="color: #F47067">!=</span><span style="color: #ADBAC7"> red){                </span><span style="color: #768390">// red value changed?</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">graph</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">,rp,</span><span style="color: #6CB6FF">RED</span><span style="color: #ADBAC7">);           </span><span style="color: #768390">// Update graph</span></span>
<span class="line"><span style="color: #ADBAC7">    old_r </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> red;</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (old_g </span><span style="color: #F47067">!=</span><span style="color: #ADBAC7"> green){              </span><span style="color: #768390">// green value changed? </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">graph</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">130</span><span style="color: #ADBAC7">,gp,</span><span style="color: #6CB6FF">GREEN</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    old_g </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> green;   </span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7">(old_b </span><span style="color: #F47067">!=</span><span style="color: #ADBAC7"> blue){               </span><span style="color: #768390">// blue value change  </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">graph</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">160</span><span style="color: #ADBAC7">,bp,</span><span style="color: #6CB6FF">BLUE</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    old_b </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> blue;</span></span>
<span class="line"><span style="color: #ADBAC7">  }   </span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">//---------SETUP------------------</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">setup</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">  Serial.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9600</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">reset</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">begin</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0x9341</span><span style="color: #ADBAC7">);  </span><span style="color: #768390">// SDFP5408</span></span>
<span class="line"><span style="color: #ADBAC7">  tft.</span><span style="color: #DCBDFB">fillRect</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">240</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">320</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">BLACK</span><span style="color: #ADBAC7">);    </span><span style="color: #768390">// Drawing area</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">palette</span><span style="color: #ADBAC7">();  </span><span style="color: #768390">// Drawing buttons</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">show</span><span style="color: #ADBAC7">();  </span><span style="color: #768390">// Display the inital values  </span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">//---------Main Loop------------</span></span>
<span class="line"><span style="color: #F47067">void</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">loop</span><span style="color: #ADBAC7">(){</span></span>
<span class="line"><span style="color: #ADBAC7">  TSPoint p </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ts.</span><span style="color: #DCBDFB">getPoint</span><span style="color: #ADBAC7">(); </span><span style="color: #768390">// Read the Touch Screen</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Shared pins - fix direction</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">pinMode</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">XM</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">OUTPUT</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #DCBDFB">pinMode</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">YP</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">OUTPUT</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #768390">// Check for pressure on screen</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (p.z </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">MINPRESSURE</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&amp;&amp;</span><span style="color: #ADBAC7"> p.z </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">MAXPRESSURE</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">      </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Scale Touch values to fit TFT screen </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Adjust final values to improve accuracy</span></span>
<span class="line"><span style="color: #ADBAC7">    p.x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">map</span><span style="color: #ADBAC7">(p.x, </span><span style="color: #6CB6FF">TS_MINX</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">TS_MAXX</span><span style="color: #ADBAC7">, tft.</span><span style="color: #DCBDFB">width</span><span style="color: #ADBAC7">(), </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    p.y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">map</span><span style="color: #ADBAC7">(p.y, </span><span style="color: #6CB6FF">TS_MINY</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">TS_MAXY</span><span style="color: #ADBAC7">, tft.</span><span style="color: #DCBDFB">height</span><span style="color: #ADBAC7">(), </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">)</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">14</span><span style="color: #ADBAC7">; </span></span>
<span class="line"><span style="color: #ADBAC7">    </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.y </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">300</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.y </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">330</span><span style="color: #ADBAC7">)){               </span><span style="color: #768390">// In the button area?</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.x </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> left[</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">]) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> right[</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">])){    </span><span style="color: #768390">// Process buttons</span></span>
<span class="line"><span style="color: #ADBAC7">        red </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> red </span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;                               </span><span style="color: #768390">//   as necessary</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (red </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">){red </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.x </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> left[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">]) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> right[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">])){ </span></span>
<span class="line"><span style="color: #ADBAC7">        red </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> red </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (red </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">){red </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.x </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> left[</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">]) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> right[</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">])){ </span></span>
<span class="line"><span style="color: #ADBAC7">        green </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> green </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (green </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span><span style="color: #ADBAC7">){green </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span><span style="color: #ADBAC7">;} </span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.x </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> left[</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">]) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> right[</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">])){ </span></span>
<span class="line"><span style="color: #ADBAC7">        green </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> green </span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (green </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">){green </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.x </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> left[</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">]) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> right[</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">])){ </span></span>
<span class="line"><span style="color: #ADBAC7">        blue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> blue </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (blue </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">){blue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">31</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #F47067">else</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> ((p.x </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> left[</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">]) </span><span style="color: #F47067">&amp;</span><span style="color: #ADBAC7"> (p.x </span><span style="color: #F47067">&lt;=</span><span style="color: #ADBAC7"> right[</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">])){ </span></span>
<span class="line"><span style="color: #ADBAC7">        blue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> blue </span><span style="color: #F47067">-</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (blue </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">){blue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">;}</span></span>
<span class="line"><span style="color: #ADBAC7">      }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// Update Display</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">show</span><span style="color: #ADBAC7">();</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre></div>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><strong>Conclusion</strong></h2>



<p class="wp-block-paragraph">There is a small amount of jitter as the bar graph re-draws, but overall, the shield works quickly and well. After the screen has updated and is waiting for a touch, the image is steady, sharp, and bright. Once you have calibrated the touch device, it is very accurate, as demonstrated by the small (30&#215;30 pixel buttons), and provides excellent, colorful graphics on a usefully large display. </p>



<p class="wp-block-paragraph">The SD card reader is a bonus and could always be used via jump wires to record values from sensors on the other pins. These values could then be displayed graphically with a different sketch.</p>



<p class="wp-block-paragraph">I was very pleased with the display&#8217;s quality and the Touch device&#8217;s accuracy. It sits neatly and securely on a UNO or a MEGA 2560. With an SD card reader included, it was excellent value, and I will make good use of it in the future.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/arduino-with-touch-screen/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Electronic DIY Metal Detector Project</title>
		<link>https://tutorial45.com/electronic-diy-metal-detector/</link>
					<comments>https://tutorial45.com/electronic-diy-metal-detector/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Nikodem Bartnik]]></dc:creator>
		<pubDate>Wed, 08 Apr 2020 13:53:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">http://tutorial45.com/?p=7010</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/electronic-diy-metal-detector/">Electronic DIY Metal Detector Project</a></p>
<p>Today, we are going to build a DIY metal detector with the help of these devices which will help make the process easy and fun. The end product, the metal detector itself once built can help you find metallic&#160;stuff under the&#160;ground, who knows what might just be buried there waiting for you! Here are the ... </p>
<p class="read-more-container"><a title="Electronic DIY Metal Detector Project" class="read-more button" href="https://tutorial45.com/electronic-diy-metal-detector/#more-7010" aria-label="More on Electronic DIY Metal Detector Project">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/electronic-diy-metal-detector/">Electronic DIY Metal Detector Project</a></p>

<p class="wp-block-paragraph">Today, we are going to build a DIY metal detector with the help of these devices which will help make the process easy and fun. The end product, the metal detector itself once built can help you find metallic&nbsp;stuff under the&nbsp;ground, who knows what might just be buried there waiting for you!</p>



<p class="wp-block-paragraph">Here are the items included in the Box:</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00122.jpg" alt="electronic parts" class="wp-image-7011" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00122.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00122-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00122-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00122-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">There are components like transistors and resistors which can look identical though there are not.</p>



<p class="wp-block-paragraph">Fortunately enough, everything is labeled on the PCB. We should not have any issue with the&nbsp;assembly of&nbsp;this kit.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00123.jpg" alt="circuit board" class="wp-image-7012" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00123.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00123-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00123-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00123-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Let’s start with all of the capacitors, those are of orange, big black, and green color. Make&nbsp;sure that polarities of the biggest black capacitor match with PCB.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00125.jpg" alt="capacitor" class="wp-image-7013" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00125.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00125-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00125-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00125-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Solder everything and cut out the legs of each component.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00126.jpg" alt="holes in a circuit board" class="wp-image-7014" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00126.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00126-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00126-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00126-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Now we have to put the two resistors in place, each of them has a different value one is 2.2k and the other is 220k. You can measure that with a multimeter. If you don’t have a multimeter make sure that it looks the same as on the image below. (You can learn <a href="https://tutorial45.com/how-to-use-a-multimeter-using/">how to use a multimeter</a> here)</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00128.jpg" alt="component mounted on a circuit board" class="wp-image-7015" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00128.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00128-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00128-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00128-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Solder everything and cut off the legs of both resistors.</p>



<p class="wp-block-paragraph">Now we have three transistors. They are different from one another, we have a 9018, 9015 and&nbsp;9012. There are labels on the PCB with exactly the same way. Simply put them in their proper&nbsp;place on the board.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00130.jpg" alt="transistors" class="wp-image-7016" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00130.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00130-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00130-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00130-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00132.jpg" alt="circuit board" class="wp-image-7017" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00132.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00132-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00132-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00132-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">In the end, we can solder the potentiometer, buzzer, and 2 cables.</p>



<p class="wp-block-paragraph">Make sure that the positive pin of the buzzer&nbsp;is where there is + on the PCB. The holes for power cables are labeled with + and -.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00133.jpg" alt="cable connection on the circuit board" class="wp-image-7018" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00133.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00133-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00133-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00133-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">And here you go!</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00134.jpg" alt="metal detector completed" class="wp-image-7019" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00134.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00134-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00134-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00134-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">To power it up, you can use anything in the range of 3 to 5V. I am using my adjustable power&nbsp;supply with the voltage adjusted to 4V.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00135.jpg" alt="power supply with circuit board" class="wp-image-7020" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00135.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00135-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00135-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Metal-Detector-DSC00135-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">You can also use normal AA or AAA batteries and use it remotely to find some treasures&nbsp;outside if you are into this kind of thing.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="DIY metal Detector project" width="800" height="450" src="https://www.youtube.com/embed/kisTXKOtZR0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/electronic-diy-metal-detector/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Electronic DIY Voice Control LED Project</title>
		<link>https://tutorial45.com/electronic-diy-voice-control-led-project/</link>
					<comments>https://tutorial45.com/electronic-diy-voice-control-led-project/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Nikodem Bartnik]]></dc:creator>
		<pubDate>Wed, 08 Apr 2020 13:25:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">http://tutorial45.com/?p=7048</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/electronic-diy-voice-control-led-project/">Electronic DIY Voice Control LED Project</a></p>
<p>We worked on creating a decibel meter using the Arduino board here and&#160;how to assemble an audio level indicator. This one is a simple and perfect electronic project for beginners. Let&#8217;s put this&#160;voice control LED board together so the LEDs blink every time noise is detected. Let’s get started. Here are the elements contained in ... </p>
<p class="read-more-container"><a title="Electronic DIY Voice Control LED Project" class="read-more button" href="https://tutorial45.com/electronic-diy-voice-control-led-project/#more-7048" aria-label="More on Electronic DIY Voice Control LED Project">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/electronic-diy-voice-control-led-project/">Electronic DIY Voice Control LED Project</a></p>

<p class="wp-block-paragraph">We worked on creating a <a href="http://tutorial45.com/arduino-projects-arduino-decibel-meter/">decibel meter</a> using the Arduino board here and&nbsp;how to assemble an <a href="http://tutorial45.com/electronic-project-diy-audio-level-indicator/">audio level indicator</a>. This one is a simple and perfect electronic project for beginners.</p>



<p class="wp-block-paragraph">Let&#8217;s put this&nbsp;voice control LED board together so the LEDs blink every time noise is detected.</p>



<p class="wp-block-paragraph">Let’s get started.</p>



<p class="wp-block-paragraph">Here are the elements contained in the set.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00131.jpg" alt="electronic components" class="wp-image-7049" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00131.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00131-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00131-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00131-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Apart from the part shown in the image above, we will need a soldering iron and a solder.</p>



<p class="wp-block-paragraph">The 3 resistors here have different values. To find out which one is which, remember you can use a multimeter if you have one or simply identify them using the image below.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00132.jpg" alt="resistors" class="wp-image-7050" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00132.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00132-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00132-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00132-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Every component and its value is labeled on the PCB. Simply make sure to put them in right&nbsp;places. Resistors are the smallest element here,&nbsp; let’s start by soldering them to PCB.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00133.jpg" alt="mouted resistor on the board" class="wp-image-7051" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00133.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00133-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00133-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00133-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Solder them and cut out the legs with cutters, do the same to rest of the components if needed.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00137.jpg" alt="cutting legs" class="wp-image-7052" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00137.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00137-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00137-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00137-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Then we can solder the transistors and capacitors.</p>



<p class="wp-block-paragraph">Each of the capacitors has different value&nbsp;but you can find the value on the side of it. It’s important to remember about the polarities when&nbsp;connecting electrolytic capacitors as well as transistors. Make sure to connect them the right way.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00138.jpg" alt="circuit board with components" class="wp-image-7053" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00138.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00138-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00138-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00138-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">There are the 5 LED’s we need to solder to the PCB.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00139.jpg" alt="led mounted on the circuit board" class="wp-image-7054" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00139.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00139-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00139-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00139-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Now, the part that will help sense music &#8211; a microphone.</p>



<p class="wp-block-paragraph">The positive pin is not labeled on the microphone but&nbsp;we can easily recognize it.</p>



<p class="wp-block-paragraph">The negative pin of the&nbsp;microphone is connected to its case.</p>



<p class="wp-block-paragraph">As you can see in the&nbsp;image below + is the&nbsp;left leg and &#8211; is&nbsp;the&nbsp;right leg of the microphone.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00140.jpg" alt="buzzer" class="wp-image-7055" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00140.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00140-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00140-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00140-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Put it in place, solder and cut out legs.</p>



<p class="wp-block-paragraph">At the end just solder the connector we will use to connect power to the board.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00141.jpg" alt="completed board diy" class="wp-image-7056" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00141.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00141-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00141-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00141-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Here is the bottom side of PCB.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00142.jpg" alt="circuit board" class="wp-image-7057" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00142.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00142-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00142-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00142-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">To power this project, I used my lab bench power supply that I set to 3V, that’s the&nbsp;voltage that&nbsp;should be supplied to the board to make it work.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00143.jpg" alt="voltages" class="wp-image-7058" srcset="https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00143.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00143-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00143-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/Electronic-DIY-Voice-Control-LED-DSC00143-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Here is how the whole works.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Electronic DIY Voice Control LED Project" width="800" height="450" src="https://www.youtube.com/embed/aAU9hI1JOZs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/electronic-diy-voice-control-led-project/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Electronic Project for Beginners: Square Wave Generator</title>
		<link>https://tutorial45.com/square-wave-generator/</link>
					<comments>https://tutorial45.com/square-wave-generator/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Nikodem Bartnik]]></dc:creator>
		<pubDate>Wed, 08 Apr 2020 01:23:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">http://tutorial45.com/?p=7029</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/square-wave-generator/">Electronic Project for Beginners: Square Wave Generator</a></p>
<p>There are a lot of tools that are useful in an electronics workshop, some are basic ones such as power supplies and multimeters but at some point, you will need more advanced tools like an&#160;oscilloscope or a function generator. Those are quite expensive but fortunately. That is why today, we are going to build&#160;a cheap&#160;DIY ... </p>
<p class="read-more-container"><a title="Electronic Project for Beginners: Square Wave Generator" class="read-more button" href="https://tutorial45.com/square-wave-generator/#more-7029" aria-label="More on Electronic Project for Beginners: Square Wave Generator">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/square-wave-generator/">Electronic Project for Beginners: Square Wave Generator</a></p>

<p class="wp-block-paragraph">There are a lot of tools that are useful in an electronics workshop, some are basic ones such as power supplies and multimeters but at some point, you will need more advanced tools like an&nbsp;oscilloscope or a function generator.</p>



<p class="wp-block-paragraph">Those are quite expensive but fortunately. That is why today, we are going to build&nbsp;a cheap&nbsp;DIY square wave generator that in some case can replace an oscilloscope.</p>



<p class="wp-block-paragraph">This is a very simple <a href="https://tutorial45.com/electronic-project-for-beginners-fiber-light/">project making it perfect for beginners</a>.</p>



<h2 class="wp-block-heading">Square wave generator</h2>



<p class="wp-block-paragraph">These are the parts included in the kit.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00554.jpg" alt="electronic components" class="wp-image-7030" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00554.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00554-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00554-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00554-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Before we start with soldering, let’s remove the protective foil from the parts forming the case.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00555.jpg" alt="plastic shield" class="wp-image-7031" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00555.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00555-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00555-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00555-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">There is an instruction leaflet in the box that helps find important information. This is of help while identifying the components and their values.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00556.jpg" alt="square wave generator circuit board diy" class="wp-image-7032" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00556.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00556-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00556-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00556-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">As always, we start with placing the smallest components and soldering them to the&nbsp;board.</p>



<p class="wp-block-paragraph">I will start with capacitors, make sure that all of the values are correct, each&nbsp;capacitor has its value different from the others.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00557.jpg" alt="square wave generator circuit board" class="wp-image-7033" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00557.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00557-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00557-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00557-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">After soldering all components, if their legs are too long cut them out.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00558.jpg" alt="square wave generator circuit board" class="wp-image-7034" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00558.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00558-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00558-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00558-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">After the capacitors, we can place the resistors in their appropriate position. On the leaflet, you can find where to put each resistor having as reference their value. Remember you can<a href="https://tutorial45.com/how-to-use-a-multimeter-using/"> use your multimeter</a> to find the resistance values of the resistors.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00559.jpg" alt="square wave generator circuit board" class="wp-image-7035" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00559.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00559-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00559-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00559-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Solder them and cut out the legs.</p>



<p class="wp-block-paragraph">Let’s solder the break out headers and the IC support.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00560.jpg" alt="square wave generator circuit board" class="wp-image-7036" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00560.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00560-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00560-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00560-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">To power it, we will use a standard DC jack, solder that together with a screw terminal that let us&nbsp;connect cables to generate our output signal.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00561.jpg" alt="square wave components" class="wp-image-7037" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00561.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00561-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00561-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00561-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">The last 3 parts to solder are the potentiometers. One of them is different so make sure to put it&nbsp;in right place.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00562.jpg" alt="square wave generator" class="wp-image-7038" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00562.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00562-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00562-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00562-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">After soldering, we can plug the IC in.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00563.jpg" alt="square wave diy generator" class="wp-image-7039" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00563.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00563-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00563-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00563-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00564.jpg" alt="completed square ware generator" class="wp-image-7040" srcset="https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00564.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00564-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00564-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/05/square-signal-generator-DSC00564-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">The last <a href="https://tutorial45.com/3d-printing-objects-with-moving-parts/">part is to build</a> the case. </p>



<p class="wp-block-paragraph">As you can see it’s quite small so it wouldn&#8217;t take lots of space on your desk. You can power it&nbsp;with a voltage in the&nbsp;range of 9-12V.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/square-wave-generator/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Capacitor Code And Values</title>
		<link>https://tutorial45.com/capacitor-values-chart-conversion/</link>
					<comments>https://tutorial45.com/capacitor-values-chart-conversion/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Andreea]]></dc:creator>
		<pubDate>Wed, 08 Apr 2020 01:20:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">https://tutorial45.com/?p=7716</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/capacitor-values-chart-conversion/">Capacitor Code And Values</a></p>
<p>BrownRedOrangeYellowGreenBlueGrey BlackRedGreenGreyVioletBlueOrangeWhite RedOrangeYellowGreenBlueViolet 1.0 nF EIA/MIL: 102 nF: Nanofarad Every engineering student or high school STEM student probably knows what a capacitor. Therefore, defining it may not be necessary but here we go. A capacitor is a passive two-terminal electronic component that stores electrical energy in an electric field. It is used to add capacitance ... </p>
<p class="read-more-container"><a title="Capacitor Code And Values" class="read-more button" href="https://tutorial45.com/capacitor-values-chart-conversion/#more-7716" aria-label="More on Capacitor Code And Values">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/capacitor-values-chart-conversion/">Capacitor Code And Values</a></p>
<div class="input"><select class="select-css" style="border-bottom: 4px solid brown;"><option class="brown" selected="selected" value="brown">Brown</option><option value="red">Red</option><option value="orange">Orange</option><option value="Yellow">Yellow</option><option value="green">Green</option><option value="blue">Blue</option><option value="grey">Grey</option></select><br />
<select class="select-css" style="border-bottom: 4px solid black;"><option selected="selected" value="black">Black</option><option value="red">Red</option><option value="green">Green</option><option value="grey">Grey</option><option value="violet">Violet</option><option value="blue">Blue</option><option value="orange">Orange</option><option value="white">White</option></select><br />
<select class="select-css" style="border-bottom: 4px solid red;"><option selected="selected" value="red">Red</option><option value="orange">Orange</option><option value="Yellow">Yellow</option><option value="green">Green</option><option value="blue">Blue</option><option value="violet">Violet</option></select></div>
<div class="output">1.0 nF</div>
<p class="eia">EIA/MIL: 102</p>
<p>nF: Nanofarad</p>
<p style="text-align: left;"><a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/11-e-learning-platform-every-engineering-student-should-know/" data-wpil-post-to-id="3005">Every engineering student or high school STEM student probably knows</a> what a capacitor. Therefore, defining it may not be necessary but here we go. A capacitor is a passive two-terminal electronic component that stores electrical energy in an electric field. It is used to add capacitance to a circuit which makes it an important part of every electronics project. It is also important to know that the physical form of capacitors vary which means there are different capacitor types currently in use.</p>
<p style="text-align: left;">Most capacitors are built to have two electrical conductors. The conductors are generally metal plates which are separated by a dielectric medium.&nbsp; The conductor used could be a foil, thin metal film or an electrolyte. The dielectric medium separating the conductors are non-conductors themselves and can be made from glass, ceramics, air, mica, or plastic film. From these descriptions, it is obvious that capacitors come in different configurations and types. To help you make easy decisions when choosing a capacitor, this article will explore the common types of capacitors available to you.</p>
<h2>The 7 Common Capacitors for Your Electronics Project</h2>
<p style="text-align: left;"><strong>Ceramic Capacitors</strong> – The ceramic capacitor is a capacitor that makes use of a ceramic as a dielectric medium to separate the conductors in the capacitor. This means these capacitors are named after the dielectric medium used and their development.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-7844" src="https://tutorial45.com/wp-content/uploads/2019/08/capacitor3.jpeg" alt="" width="800" height="533" srcset="https://tutorial45.com/wp-content/uploads/2019/08/capacitor3.jpeg 1600w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor3-300x200.jpeg 300w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor3-768x512.jpeg 768w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor3-1024x682.jpeg 1024w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p style="text-align: left;">The use of ceramics and ceramic capacitors provide multiple benefits to the user. These benefits include:</p>
<ul>
<li style="text-align: left;">A low loss factor which guarantees a reasonable level of stability when used.</li>
<li>Its tight tolerances make it the commonly used option in RF circuits.</li>
<li>Monolithic multi-layer ceramics can also be used as by-pass capacitors.</li>
<li>It is relatively more affordable and it delivers high capacitance for your applications.</li>
</ul>
<p style="text-align: left;">The common ceramic capacitor used are the COG – for low capacitance values, the X7R – for higher capacitance, and the Z5U is used for higher capacitance but delivers lower stability than COG or X7R.</p>
<p style="text-align: left;"><strong>Electrolytic Capacitors</strong> – The electrolytic capacitor takes its name from its build. In its case, an electrolyte-soaked sheet is generally placed between two aluminum conductor films. The electrolytic capacitor is the most common leaded type used. When used, it is recommended that the rated working voltage should not be exceeded. This is because electrolytic capacitors are prone to damage.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-7848" src="https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code.jpeg" alt="" width="800" height="533" srcset="https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code.jpeg 1600w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-300x200.jpeg 300w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-768x512.jpeg 768w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-1024x682.jpeg 1024w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p style="text-align: left;">The applications and benefits of using an electrolytic capacitor include:</p>
<ul>
<li>It is a polarized capacitor commonly used in smoothening or filtering power supply rails.</li>
<li style="text-align: left;">Its low stability level means it should be used in non-critical applications such as in timing elements.</li>
<li>They do not function well in high-frequency environments. Electrolytic capacitors should be used for frequencies lower than 100KHZ</li>
</ul>
<p style="text-align: left;"><strong>Tantalum Capacitors</strong> – Tantalum capacitors are popular used in applications where the physical size of a capacitor is a consideration. This is because they are much smaller than the traditional aluminum capacitors used in different devices. The capacitors build integrates a film of oxide and tantalum. These serve as the conductor and dielectric medium. Tantalum generally do not have high working voltages and coupled with their sizes, these features make them popular with electronics creators.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-7845" src="https://tutorial45.com/wp-content/uploads/2019/08/capacitor2.jpeg" alt="" width="800" height="533" srcset="https://tutorial45.com/wp-content/uploads/2019/08/capacitor2.jpeg 1600w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor2-300x200.jpeg 300w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor2-768x512.jpeg 768w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor2-1024x682.jpeg 1024w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p style="text-align: left;">The applications and benefits of Tantalum include:</p>
<ul>
<li>They are polarized capacitors and may combust under excessive stress.</li>
<li style="text-align: left;">They have a lower series equivalent resistance compared to other options.</li>
<li>The generally have a lower voltage and 35 volts is usually the maximum of any Tantalum capacitor.</li>
</ul>
<p style="text-align: left;"><strong>Polyester Capacitors</strong> – If the name ‘polyester’ does not ring a bell, do not fret. Polyester capacitors are also called different names such as a Mylar or PET capacitor. The naming options is due to the material used with these capacitors.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-7843" src="https://tutorial45.com/wp-content/uploads/2019/08/capacitor5.jpeg" alt="" width="800" height="533" srcset="https://tutorial45.com/wp-content/uploads/2019/08/capacitor5.jpeg 1600w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor5-300x200.jpeg 300w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor5-768x512.jpeg 768w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor5-1024x682.jpeg 1024w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p style="text-align: left;">Mylar is the materials used as a dielectric medium and this material is sometimes called polyester or Polyethylene terephthalate (PET). The properties, applications, and benefits of polyester capacitors include:</p>
<ul>
<li style="text-align: left;">Polyester offers enhanced dielectric strength which makes it possible to develop small capacitors with high voltage.</li>
<li>They are generally green in color and are affordable. The general color of this capacitor has also earned it the name ‘green caps’.</li>
<li>A low tolerance of less than 10% means these capacitors can be used in diverse applications.</li>
</ul>
<p style="text-align: left;"><strong>Polycarbonate Capacitors</strong> – Once again, the dielectric medium used lends its name to a capacitor. The polycarbonate capacitor consists of a polycarbonate dielectric that delivers stability and high tolerance. Although Polycarbonate capacitors are common, it is usually used as a second option to other capacitor types. The polycarbonate dielectric medium is constructed in a foil format with metallic electrodes serving as the conductors.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-7846" src="https://tutorial45.com/wp-content/uploads/2019/08/capacitor1.jpeg" alt="" width="800" height="533" srcset="https://tutorial45.com/wp-content/uploads/2019/08/capacitor1.jpeg 1600w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor1-300x200.jpeg 300w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor1-768x512.jpeg 768w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor1-1024x682.jpeg 1024w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p style="text-align: left;">The properties, applications, and benefits of a polycarbonate capacitor includes:</p>
<ul>
<li style="text-align: left;">A high insulation resistance and a low dissipation factor.</li>
<li>It can operate optimally in temperatures as low as -55C and as high as 125C.</li>
<li>Polycarbonate capacitors can be self-healing as it vaporizes defective electrodes which restores the capacitor to life.</li>
</ul>
<p style="text-align: left;"><strong>Polystyrene Capacitor</strong> – Although polystyrene capacitors are not widely used as others on this list, they are quite common and have interesting properties. Firstly, the capacitors make use of polystyrene dielectric medium between its conductors. The characteristics of polystyrene capacitors are high insulation, low leakage, and excellent temperature stability.</p>
<p style="text-align: left;">They are also relatively affordable and their properties, applications, and benefits include:</p>
<ul>
<li>They are generally applied in audio devices or hardware.</li>
<li style="text-align: left;">They exhibit low leakage and low dielectric absorption which means a longer life span when used.</li>
<li>They are not as available for purchase like other options due to their limited use in electronics.</li>
</ul>
<p style="text-align: left;"><strong>Polypropylene Capacitor &#8211; </strong>Propylene capacitors are generally available or built as leaded components. These capacitors make use of a polypropylene dielectric which means they can be used where high degree of tolerance is a consideration. Polypropylene capacitors are commonly used in loud speakers as it guarantees enhanced-performance.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-7847" src="https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-and-value.jpeg" alt="" width="800" height="533" srcset="https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-and-value.jpeg 1600w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-and-value-300x200.jpeg 300w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-and-value-768x512.jpeg 768w, https://tutorial45.com/wp-content/uploads/2019/08/capacitor-code-and-value-1024x682.jpeg 1024w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p style="text-align: left;">The properties and benefits of polypropylene includes:</p>
<ul>
<li style="text-align: left;">They exhibit high stability which makes them best for applications where capacitance stability is an important consideration.</li>
<li>They are only available as leaded components and cannot be surface-mounted.</li>
</ul>
<h2>Summary</h2>
<p style="text-align: left;">The common capacitor types listed here are versatile options that can be used in most applications. But it is important to note that some capacitors function better in certain applications when compared to others. Thus, it is <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/cad-workstation-important-tips-consider/" data-wpil-post-to-id="4846">important to always consider</a> the application you need a capacitor for before choosing any of these capacitor types listed here.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/capacitor-values-chart-conversion/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Reasons Why You Should Use PCBWay for Your Next PCB Project</title>
		<link>https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/</link>
					<comments>https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Andreea]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 21:56:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">https://tutorial45.com/?p=7617</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/">Reasons Why You Should Use PCBWay for Your Next PCB Project</a></p>
<p>The rise of IoT, Industry 4.0 and the smart revolution has triggered a butterfly effect on the electronics/hardware industry. This trend has led to electronics manufacturers having to innovate or be eaten by the competition. It has also led to an influx of new blood interested in taking over the electronics space and PCBWay is ... </p>
<p class="read-more-container"><a title="Reasons Why You Should Use PCBWay for Your Next PCB Project" class="read-more button" href="https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/#more-7617" aria-label="More on Reasons Why You Should Use PCBWay for Your Next PCB Project">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/">Reasons Why You Should Use PCBWay for Your Next PCB Project</a></p>

<p class="wp-block-paragraph">The rise of IoT, Industry 4.0 and the smart revolution has triggered a butterfly effect on the electronics/hardware industry. This trend has led to electronics manufacturers having to innovate or be eaten by the competition. It has also led to an influx of new blood interested in taking over the electronics space and <a rel="nofollow noopener noreferrer" href="https://www.pcbway.com/" target="_blank">PCBWay</a> is one of them.</p>



<p class="wp-block-paragraph">Although everyone upsells their PCBs as the best in the business, the pudding is still in the eating. This is why in order to confirm what PCBWay PCBs have to offer, we took upon the task of creating a simple home controller using a PCB. And before discussing the details of how PCBWay stands out, here is an outline of the project I undertook.</p>



<h2 class="wp-block-heading">Designing the Simple Home Control System</h2>



<p class="wp-block-paragraph"><strong>Scope of Project</strong>: As stated earlier, the goal was to create an interconnected home system tasked with accomplishing simple exercises. The <a href="https://tutorial45.com/electronic-diy-voice-control-led-project/">project consisted of 6 push buttons and 6 LED</a> paired with the push buttons. The push buttons were designed with the aim of controlling common devices that can be found in a home. Their functions include; controlling window opening mechanisms, controlling a fan, or switching a light bulb on and off.</p>



<p class="wp-block-paragraph"><strong>Executing the Project</strong>— the first step, as always, was determining the functionalities of the circuit. Here, we drafted the circuit for the home control system on a white board and enlisted the help of <a href="https://tutorial45.com/arduino-projects-building-mini-arduino-shield-kicad-part-1/">KiCAD to design the PCB</a>. The final schematic designs were generated in Gerber files and we proceeded to send the designs to PCBWay.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="840" height="772" src="https://tutorial45.com/wp-content/uploads/2019/03/2.png" alt="schematic electronic board" class="wp-image-7619" srcset="https://tutorial45.com/wp-content/uploads/2019/03/2.png 840w, https://tutorial45.com/wp-content/uploads/2019/03/2-300x276.png 300w, https://tutorial45.com/wp-content/uploads/2019/03/2-768x706.png 768w" sizes="(max-width: 840px) 100vw, 840px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="649" height="485" src="https://tutorial45.com/wp-content/uploads/2019/03/Capture.png" alt="electronic board" class="wp-image-7618" srcset="https://tutorial45.com/wp-content/uploads/2019/03/Capture.png 649w, https://tutorial45.com/wp-content/uploads/2019/03/Capture-300x224.png 300w, https://tutorial45.com/wp-content/uploads/2019/03/Capture-320x240.png 320w" sizes="(max-width: 649px) 100vw, 649px" /></figure></div>



<p class="wp-block-paragraph"><strong>PCBWay</strong> –This is where PCBWay comes into the picture. First and foremost, it is important to state that PCBWay sent the physical PCB to us in a timely fashion. And when the PCB arrived, we soldered the components on the board and tested the design without encountering any hurdles. We then programmed a microcontroller chip to the behavioural patterns assigned to each buttons. The testing process was seamless and the home control system worked perfectly.</p>



<p class="wp-block-paragraph"><strong>Our Verdict</strong>—the response from PCBWay was timely and professional. We actually made a mistake by sending the incomplete Gerber files in and received feedback about this immediately. On providing the complete files, we received the final PCB within 2 weeks.</p>



<h2 class="wp-block-heading">Reasons Why We Recommend PCBWay<strong><br></strong></h2>



<p class="wp-block-paragraph">With the scope of the simple project executed out of the way, now is the time to examine the pros of using PCBWay. Here, we have outlined the six most important reasons why PCBWay stands out from its competitors.</p>



<h3 class="wp-block-heading">High Quality Raw Materials</h3>



<p class="wp-block-paragraph">As we all know, the quality of raw materials used in developing a board plays a huge role in its effectiveness as a conduit. From our little project, it was easy to detect that PCBWay makes use of quality raw materials in developing PCBs. Their ability to do this is due to the use of PTH technology on their boards. PCBWay’s use of quality raw material on a regular basis is also made possible by integrate quality control checks.</p>



<p class="wp-block-paragraph">PCBWay’s boards are routinely inspected by the relevant professional bodies to ensure the highest quality is adhered to. Some of the parameters quality control professionals inspect are: the copper thickness, signal reaction, and anomaly detection ability of components. In conclusion, the PCBWay board we used for the test project passed our checks with flying colours. The board was responsive and better produced than the majority of PCBs we have previously used.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="533" src="https://tutorial45.com/wp-content/uploads/2019/03/IMG_8242.jpg" alt="box" class="wp-image-7620" srcset="https://tutorial45.com/wp-content/uploads/2019/03/IMG_8242.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/03/IMG_8242-300x200.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/03/IMG_8242-768x512.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="670" height="527" src="https://tutorial45.com/wp-content/uploads/2019/03/IMG_8243-e1552946148102.jpg" alt="electronic boards" class="wp-image-7621" srcset="https://tutorial45.com/wp-content/uploads/2019/03/IMG_8243-e1552946148102.jpg 670w, https://tutorial45.com/wp-content/uploads/2019/03/IMG_8243-e1552946148102-300x236.jpg 300w" sizes="(max-width: 670px) 100vw, 670px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="533" src="https://tutorial45.com/wp-content/uploads/2019/03/IMG_8552.jpg" alt="final electronic projects" class="wp-image-7623" srcset="https://tutorial45.com/wp-content/uploads/2019/03/IMG_8552.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/03/IMG_8552-300x200.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/03/IMG_8552-768x512.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<h3 class="wp-block-heading">Ability to Track the Progression of Your PCB Production in Real-Time</h3>



<p class="wp-block-paragraph">As stated earlier, our experiences with PCBWay’s customer unit was great. One important reason why this was so, is the real-time tracking service PCBWay has to offer. What does real-time tracking mean, you may ask? The real-time tracking feature allows you to track two aspects of your <a href="https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/">PCB design</a> phase. These aspects are the status of the project been developed, and even the progression of your shipment! This is a service other PCB manufacturers do not offer!</p>



<p class="wp-block-paragraph">Using the PCBWay backend, we were able to easily track the production stages for our PCB and knew when to expect it to be completed. We were also provided with a shipment express number. This allowed us track our PCB shipment and expect its delivery when it came.</p>



<h3 class="wp-block-heading">A Vibrant PCBWay Online Community</h3>



<p class="wp-block-paragraph">when designing new PCBs, everyone knows that collaboration has a role to play. By collaboration, we mean some inputs, assistance, or correction from more-experienced heads. The <a href="https://www.pcbway.com/project/shareproject" target="_blank" rel="nofollow noopener noreferrer">PCBWay community</a> provides you abundance assistance when needed. You can easily share your PCB designs in the PCBWay community and receive feedback from other electronics enthusiast.</p>



<p class="wp-block-paragraph">As an aside, the PCBWay community provides you with an avenue to earn real cash. On posting your PCB design to the PCBWay Community; your designs could be purchased by interested third-parties. 10% of every purchase or order attached to your PCB design is given back to you! Lastly, PCBWay regularly conducts hackathons were great PCB designs are showcased to the public. After voting has been concluded, the winner is awarded a cash price to encourage him or her to do more.</p>



<h3 class="wp-block-heading">The Most-affordable Prototyping Cost Available to You</h3>



<p class="wp-block-paragraph">The <a href="https://tutorial45.com/6-reasons-to-build-your-next-arduino-project-with-xod/">reason why you outsource your PCB prototyping projects</a> is probably due to quality control. PCBWay gives electronics enthusiast another reason to outsource prototyping. And this reason is low prototyping cost. A PCBWay prototyping task costs approximately $5 or $10 depending on the scope of work. This is currently the cheapest prototyping cost in today’s PCB market.</p>



<p class="wp-block-paragraph">Students, new registrants, and anyone strapped for cash can also take advantage of the PCBWay special coupon offer. Using the special coupon could mean that you end up paying not a single dime to get your prototyping done.</p>



<h3 class="wp-block-heading">PCBWay Sponsorship for Non-profit Project</h3>



<p class="wp-block-paragraph">PCBWay continues to play an important role in helping students get their <a href="https://tutorial45.com/electronic-project-diy-electronic-clock/">electronic projects</a> off the ground. An example of this was their support of the Makerfaire SHA 2017 event. The dedicated sponsorship programme is open to students, beginners and NGO’s looking to develop something creative in the field of robotics and IoT devices.</p>



<h3 class="wp-block-heading">Great After-Sale Services</h3>



<p class="wp-block-paragraph">With PCBWay, your complaints, changes, and needs are truly catered to. As explained earlier, our Gerber folder was missing a few files. PCBWay contacted us and after providing the files, we <a href="https://tutorial45.com/arduino-ir-receiver/">received feedback concerning our project</a> within a day.</p>



<p class="wp-block-paragraph">Now, the PCBWay after-sales team takes responsiveness to greater heights. And every complaint you have to make is answered within 24 hours. You can also take advantage of the PCBWay background system to lay your complaints on any issues you have. You will receive a response in 24 hours and according to international standards, a response ticket will be created for you immediately.</p>



<h2 class="wp-block-heading">Our Conclusion</h2>



<p class="wp-block-paragraph">Working with PCBWay was an experience we intend to continue enjoying. This is because of the low prototyping prices on offer and the quick-response times we experienced. Therefore, PCBWay gets more than a pass mark from us, as we also endorse them as our PCB prototyping service of choice. You can also take advantage of the many benefits they offer by scheduling a <a href="https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/">PCB prototyping</a> project with them today.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Best PCB Design Software for Electrical Engineers</title>
		<link>https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/</link>
					<comments>https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Andreea]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 21:56:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">https://tutorial45.com/?p=7667</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/">Best PCB Design Software for Electrical Engineers</a></p>
<p>Everyone investing time in developing electronics or IoT hardware needs a PCB. Whether you are a sophomore, an enthusiastic DIYer or a professional innovator, the PCB still remains an important aspect of your electronics project. Therefore, it is only right to state that designing a PCB is the most crucial task you will be involved ... </p>
<p class="read-more-container"><a title="Best PCB Design Software for Electrical Engineers" class="read-more button" href="https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/#more-7667" aria-label="More on Best PCB Design Software for Electrical Engineers">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/">Best PCB Design Software for Electrical Engineers</a></p>

<p class="wp-block-paragraph">Everyone investing time in developing electronics or IoT hardware needs a PCB. Whether you are a sophomore, an enthusiastic DIYer or a professional innovator, the PCB still remains an important aspect of your electronics project. Therefore, it is only right to state that designing a PCB is the most crucial task you will be involved with during your creative task.</p>



<p class="wp-block-paragraph">Now, to design the layout of your PCB in this digital age, you will require a PCB design software app. And in terms of choice, there are multiple options out there. This is why this post will focus on helping students looking to kick start projects, DIYers, and pros looking for other options find the best PCB design software. But before delving into the different available options, the factors you need to consider include the following:</p>



<ul class="wp-block-list"><li>What is my budget?</li><li>Do I intend to work on professional projects?</li><li>Which <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/best-operating-systems-for-raspberry-pi-os/" data-wpil-post-to-id="7827">operating system</a> do I use?</li><li>Do I intend to share designs in maker spaces?</li><li>How difficult is a software’s learning curve</li><li>What works best for single, double or multi-layered PCBs?</li></ul>



<p class="wp-block-paragraph">Your answer to these questions should determine the PCB <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/best-free-furniture-design-software/" data-wpil-post-to-id="5770">design software</a> you end up choosing. Therefore, the best options in each budget category and feature wise will be listed here.</p>



<h2 class="wp-block-heading">The Top Free PCB Design Software for Students</h2>



<p class="wp-block-paragraph">Starting with test free PCB <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/best-free-furniture-design-software/" data-wpil-post-to-id="5770">design software</a> which are great for students and DIY enthusiasts looking to spend nothing, here are your best options:</p>



<h3 class="wp-block-heading">Easy EDA</h3>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Auto Router" width="800" height="450" src="https://www.youtube.com/embed/fQiwFJ21_Xg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">When in search of a versatile free web-based electronic design automation software app, you can’t go wrong with EasyEDA. As a web-based tool, all you need is to visit the EasyEDA website through your browser to get started. As a web-based tool, EasyEDA is compatible with every operating system. Therefore, you can start designing a PCB on your Linux, Windows or Mac-based OS immediately.</p>



<p class="wp-block-paragraph">Taking a look at its features, its user-friendly interface means designing PCBs is a relatively easy task. Also, the vibrant EasyEDA online community means you can take advantage of the hundreds of tutorials available on its forums. On the flip side, you can chat with more experienced designers or even borrow a free <a href="https://tutorial45.com/reasons-why-you-should-use-pcbway-for-your-next-pcb-project/">PCB design to use for your project</a>. EasyEDA is also friendly to a collaborative effort. This is due to the fact that you can import libraries and schematic drawings from other applications such as EAGLE or Altium. You can do this without facing any compatible issues.</p>



<p class="wp-block-paragraph">The tools EasyEDA provides for your design task, includes the EasyEDA library, a design manager, drawing and wiring toolbars, and the choice of purchasing components from third parties.</p>



<h3 class="wp-block-heading">Circuit Maker</h3>



<p class="wp-block-paragraph">Another great free electronic design automation (EDA) tool to look out for or consider is the Circuit Maker. Circuit Maker was designed with the sole aim of giving PCB designers a free EDA application with professional features to work with. This fact is reinforced once you know that the Circuit Maker was developed by industry heavyweights, Altium. As a web-based application, this EDA tool is compatible with most <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/best-operating-systems-for-raspberry-pi-os/" data-wpil-post-to-id="7827">operating systems</a> and is equipped with both design and collaborating features you would find helpful.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="EEVblog #754 - Altium Circuit Maker First Impressions" width="800" height="450" src="https://www.youtube.com/embed/TWcL0OF_eQI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Some of the features to look out for include; extensive push and shove routing capabilities, the choice of editing multi-sheet schematics, one-click manufacturing, etc. The ability to also easily collaborate with other makers on Altium’s extensive community is one that appeals too many designers. The Circuit maker is totally free and compatible with other established PCB EDAs such as EAGLE, OrCAD, pCAD, etc. This makes importing designs from these applications into Circuit Maker possible. As great as the CircuitMaker is, note that it does not have all the premium features that come with the paid Altium EDA.</p>



<h3 class="wp-block-heading">KiCAD</h3>



<p class="wp-block-paragraph">If this was a popularity contest, KiCAD easily wins this as it is the most popular EDA application in the free category. First and foremost, it is important to state that KiCAD is a suite of offline applications. Therefore knowing its compatibility status with different operating systems is important. Thankfully, KiCAD is a cross-platform application and can be installed/used on the Windows, Linux, and Mac operating systems. And unlike the Circuit Maker, the KiCAD application is totally free and you do not have to pay to unlock any premium features.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" src="https://tutorial45.com/wp-content/uploads/2017/10/Arduino-Shiled-projects-7.png" alt="Kicad pcb design software"/></figure></div>



<p class="wp-block-paragraph">With KiCAD, you have a versatile schematic editor with a friendly user interface. This makes it possible to quickly learn how to design with this app and start creating with ease. KiCAD is also quite extensive in its application and you can create a 32-layered PCB using this free resource. You can also take advantage of its 3D viewer for interactive designing and its vibrant community for tips. All these features make design and collaborating or sharing your ideas easy to accomplish. KiCAD also has its dedicated library and can integrate libraries from other EDA tools which are also great for collaboration.</p>



<h3 class="wp-block-heading">DesignSpark PCB</h3>



<p class="wp-block-paragraph">If you are into schematic designs for <a href="https://tutorial45.com/iot-projects-ideas/" >IoT projects</a> and other smart devices, this EDA tool might just be the best thing you will ever come across. The DesignSpark PCB is great for mechanical and electronic designs. In terms of compatibility with operating systems, DesignSpark PCB is native to the different Windows operating systems. But with emulation <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/easy-cad-software-applications-anyone-can-use/" data-wpil-post-to-id="4097">software applications,</a> you can get this EDA application to run on your Mac or Linux-powered computer. DesignSpark PCB has a truly extensive library with over a million parts and a vibrant community contributing to its library.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="DesignSpark PCB Training | 1 Familiarisation" width="800" height="450" src="https://www.youtube.com/embed/eTwi5dWOVzQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Note that DesignSpark PCB is a standalone suite that needs to be installed on your PC. Therefore, you have to be mindful of its installation requirements. Once that is out of the way, you have the following features to take advantage off; limitless schematic sheets to work with, create a bill of materials however you choose, etc. Other features that make the DesignSpark PCB designer a great tool is the option of creating your own libraries for your peculiar projects. DesignSpark is also user-friendly and you can seamlessly integrate external projects into your existing workflows.</p>



<h3 class="wp-block-heading">Fritzing</h3>



<p class="wp-block-paragraph">If you are big on trying new software applications, then the Fritzing EDA is a tool you should consider. This product of a collective German maker community is a simplistic PCB design software with extensive features which you can use for your electronics projects. Fritzing is compatible with Windows, Linux and, Mac operating systems. As an open-source EDA, the Fritzing is totally free and all you need to get started is its suite files. Some of the features to look out for are the Fritzing fab and its compatibility abilities. The Fritzing Fab allows you to turn your circuits into a customized PCB with ease. Although the creation process is cheap, it is by no means free.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Fritzing - An Introduction" width="800" height="600" src="https://www.youtube.com/embed/Hxhd4HKrWpg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">You can also import libraries and designs done on other PCB design applications into the Fritzing user-interface. The software makes use of a simplistic approach to design which may just produce the creative spark you are looking for.</p>



<h2 class="wp-block-heading">The Top Paid PCB Design Software Applications for You</h2>



<p class="wp-block-paragraph">Now, industrial electronics manufacturers may require a PCB design software with advanced features for their work. If you fall into this category, a paid EDA tool may just be the solution you need. So, here are the top PCB design tools you should use for your schematic design applications.</p>



<h3 class="wp-block-heading">Altium Designer</h3>



<p class="wp-block-paragraph">Altium has become a household name in the electronics and hardware design industry due to its extensive professional use. With Altium, you can work on diverse variables of any project without having to create new projects to accommodate your ideas. Other features you would use extensively are its real-time design process which integrates the price, features, and availability of parts into a project. Altium also promises a speedy design process due to certain features it offers. One of such feature is its routing engine which allows you to manipulate different components quickly. Its Native <a class="" style="display: inline !important; width: auto !important;" data-wpil-post-to-id="2717" href="https://tutorial45.com/3d-design-project-for-beginners-a-stool/">3D design</a> is also quite helpful with design and troubleshooting schematics.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Overview of Altium Designer 20" width="800" height="450" src="https://www.youtube.com/embed/2HC0zjFe89o?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">It is important to state that Altium is only available on the Windows operating system. But this limitation does not extend to its compatibility with other EDA tools. You can choose to import your projects into Altium’s workspace and make use of its pro features. As stated earlier, Altium is a paid software suite but you can choose to reduce its cost by taking advantage of its partner packages.</p>



<h3 class="wp-block-heading">EAGLE</h3>



<p class="wp-block-paragraph">Autodesk’s sojourn into the EDA or PCB <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/cad-projects-for-beginners/" data-wpil-post-to-id="2594">design software space started with its introduction of 123D</a> Circuits. But its successful purchase of EAGLE saw that effort integrated into the more versatile and powerful EAGLE suite. That being said, EAGLE definitely delivers as a professional PCB design application. It provides you with a powerful schematic editor, intuitive PCB layout tools, 3D design, and a vibrant online community to take advantage off. Eagle is compatible with the popular Windows, Linux, and Mac operating systems. Therefore, it can be easily integrated in offices that make use of PCs with varying operating systems.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="997" height="480" src="https://tutorial45.com/wp-content/uploads/2020/04/eagle-1.png" alt="Eagle pcb design software" class="wp-image-9554" srcset="https://tutorial45.com/wp-content/uploads/2020/04/eagle-1.png 997w, https://tutorial45.com/wp-content/uploads/2020/04/eagle-1-300x144.png 300w, https://tutorial45.com/wp-content/uploads/2020/04/eagle-1-768x370.png 768w, https://tutorial45.com/wp-content/uploads/2020/04/eagle-1-585x282.png 585w" sizes="(max-width: 997px) 100vw, 997px" /></figure>



<p class="wp-block-paragraph">Like with most Autodesk offerings, the entire EAGLE package must be paid for before use. And everyone gets a free monthly trial to decide if the EAGLE is for them. Students are also allowed to use a limited version of EAGLE without paying for it.</p>



<h3 class="wp-block-heading">OrCAD</h3>



<p class="wp-block-paragraph">Another <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/the-most-popular-cad-software/" data-wpil-post-to-id="1417">popular PCB design software</a> you should consider for professional use is OrCAD. This design software built in Oregon for PCB design purposes and for simulation. This is why the complete OrCAD suite includes; the OrCAD Capture and PSpice. OrCAD capture is the suite needed for your schematic PCB designs. It integrates user-friendly tools and professional-grade features that will intuitively assist your design projects.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="583" src="https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1-1024x583.jpg" alt="orcad pcb design software" class="wp-image-9555" srcset="https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1-1024x583.jpg 1024w, https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1-300x171.jpg 300w, https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1-768x438.jpg 768w, https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1-1170x667.jpg 1170w, https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1-585x333.jpg 585w, https://tutorial45.com/wp-content/uploads/2020/04/OrCAD-1.jpg 1348w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">The PSpice suite is a simulation and verification tool used in verifying the applicability of circuits. Electronic manufacturers use the PSpice suite for reliability, cost, and yield analysis. OrCAD is capable of simulating circuit designs from other <a class="" style="display: inline !important; width: auto !important;" href="https://tutorial45.com/easy-cad-software-applications-anyone-can-use/" data-wpil-post-to-id="4097">software applications</a> such as MATLAB and Simulink. This makes it quite unique when compared to other PCB design software applications in its category. OrCAD is definitely not a free software package. You can choose to manage how much you spend by selecting the cheaper packages OrCAD offers its professional users. Finally, OrCAD also boasts of a vibrant <a href="https://tutorial45.com/arduino-wireless-communication-project/">community which can provide you with the support you may need when working on a project</a>.</p>



<h3 class="wp-block-heading">Multisim</h3>



<p class="wp-block-paragraph">This is an advanced, industrial-grade PCB design software package that can be used by students, pros, and researchers. The Multisim package also consists of a PCB schematic design tool and a simulation package for circuit analysis. The greatest selling point of Multisim is its vibrant learning environment that supports everyone. The tool provides an extensive library and an easy schematic-to-prototyping process for industrial use.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Basic Use of Multisim In Electronics Circuit Analysis Lab Tips" width="800" height="450" src="https://www.youtube.com/embed/JaY7juStarE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Multisim is also great for researching and analyzing design tasks with a view to reducing errors and enhancing the performance of your design. Although this PCB design software is a paid option, its student’s suite is free and allows you to take advantage of its versatile features at need.</p>



<h3 class="wp-block-heading">Allegro PCB Designer</h3>



<p class="wp-block-paragraph">Allegro offers a diverse range of suites with different features matching your current design need. This means if you require a tool for speedy design projects, you can use its high-speed option, and if you intend to collaborate, its team design option is also available. In terms of ease of use, the Allegro user-interface is quite friendly and provides you with the PCB design tools you will need for your projects.</p>



<p class="wp-block-paragraph">As with most professional PCB design software applications, Allegro isn’t free. But it comes with a versatile payment plan that allows you to pay for only the design features you require. Allegro is compatible with Windows, Linux, and Mac operating systems.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">There are a variety of PCB design software applications you can choose to use for your <a href="https://tutorial45.com/electronic-project-diy-electronic-clock/">electronics projects</a>. These tools have varying capacities and features therefore; your design requirements should determine your choice. That being said, when finally taking the schematics-to-prototyping step, PCBWay can help develop your schematics into high-performing board regardless of how complex your schematics are.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding the Basics of Printed Circuit Boards: The Designing, Components, and Construction</title>
		<link>https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/</link>
					<comments>https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Andreea]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 21:37:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">https://tutorial45.com/?p=7594</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/">Understanding the Basics of Printed Circuit Boards: The Designing, Components, and Construction</a></p>
<p>One of the major driving forces behind how electronics and other hardware function is the printed circuit board (PCB). This fact is something everyone interested in electronics knows. But for software designers and other non-technical people, a PCB is basically a connector or bridge that supports electrical connections within a device. Therefore, before taking advantage ... </p>
<p class="read-more-container"><a title="Understanding the Basics of Printed Circuit Boards: The Designing, Components, and Construction" class="read-more button" href="https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/#more-7594" aria-label="More on Understanding the Basics of Printed Circuit Boards: The Designing, Components, and Construction">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/">Understanding the Basics of Printed Circuit Boards: The Designing, Components, and Construction</a></p>

<p class="wp-block-paragraph">One of the major driving forces behind how electronics and other hardware function is the printed circuit board (PCB). This fact is something everyone interested in electronics knows. But for software designers and other non-technical people, a PCB is basically a connector or bridge that supports electrical connections within a device. Therefore, before taking advantage of the benefits they offer, you must first understand PCBs.</p>



<p class="wp-block-paragraph">In tech-speak, a printed <a href="https://tutorial45.com/printed-circuit-board-holder-soldering/">circuit board</a> is a board that mechanically support and electronically connects electronic components in devices. It accomplishes this task through the use of conductive tracks, pads, and other features. These features are usually etched on sheet layers of copper and laminated onto layers of a nonconductive substrate. The components of a PCB are generally or always fastened to the board by soldering.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How Do PCBs Work?" width="800" height="450" src="https://www.youtube.com/embed/H9pGbLJknDk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Using simpler language, the PCB is a board made from plastic which has been reinforced with glass. And attached to the board are copper lines and pads that allow an <a href="https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/">electrical charge to pass through the PCB</a> to the components of a device. If you have ever opened a calculator or <a href="https://tutorial45.com/engineering-games-for-kids/">game controller out of curiosity as a kid</a>, you have seen a PCB.</p>



<h2 class="wp-block-heading">Properties and Characteristics of a PCB</h2>



<p class="wp-block-paragraph">A PCB has distinct characters and components that must be understood before designing or using one. Starting with the conductive tracks, which are also known as circuit traces, the tracks serve as wires. But in this case, they are firmly kept in place and are separated or insulated by air and the substrate material of the board. The conductive tracks have been highlighted in the image below.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="805" height="605" src="https://tutorial45.com/wp-content/uploads/2019/02/the-basics-of-printed-circuit-boards-design-components-and-construction.jpg" alt="electronic board with parts" class="wp-image-7595" srcset="https://tutorial45.com/wp-content/uploads/2019/02/the-basics-of-printed-circuit-boards-design-components-and-construction.jpg 805w, https://tutorial45.com/wp-content/uploads/2019/02/the-basics-of-printed-circuit-boards-design-components-and-construction-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/02/the-basics-of-printed-circuit-boards-design-components-and-construction-768x577.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/02/the-basics-of-printed-circuit-boards-design-components-and-construction-320x240.jpg 320w" sizes="(max-width: 805px) 100vw, 805px" /></figure></div>



<ol class="wp-block-list"><li>Conductive tracks</li><li>through-holes</li><li>Components</li></ol>



<p class="wp-block-paragraph">A PCB is also designed with pads and this serves as connectors, while vias pass the connection between the board’s layers of copper and other solid conductive features on the board. Depending on what a board is built to achieve, other conductors, and components are usually mounted on the board. A PCB can be designed to have multiple copper layers according to how they will be applied. For example, a two-layer has copper layers on both sides of the board. A multi-layered board integrates even more copper layers between the layers of its insulating material.</p>



<p class="wp-block-paragraph">The components on a PCB are mounted on it through two popular methods. The first is method involves through-holes. Here, components with wire leads are passed through the board and are soldered to traces on the other end. This mechanically keeps the component in place and connects it electronically through the traces. The second mounting technique is the surface-mount. Here, the component lead is soldered to traces on the same surface as the component.</p>



<p class="wp-block-paragraph">Both mounting methods are generally used interchangeably on a circuit board. The old rule of thumb, which is still efficient, is heavier components like capacitors should be secured using a through-hole and lighter components using a surface-hole. Lastly, the pattern to be etched on the copper layers is called artworks. Artworks are designed using photoresist and are etched firmly by light exposure. Now you know the basics and different components of the board, understanding the design process is the next phase.</p>



<h2 class="wp-block-heading">The Techniques for Designing a PCB Board</h2>



<p class="wp-block-paragraph">There are a couple of ways to go about designing a PCB board. The three commonly used methods are:</p>



<ol class="wp-block-list"><li>Iron on glossy paper</li><li>Circuit by hand on PCB</li><li>Laser cutting edge etching method.</li></ol>



<p class="wp-block-paragraph">With these three methods, the basic design process still remains the same. The <a href="https://tutorial45.com/best-free-furniture-design-software/">design process is started by drafting the schematics for your board using CAD software</a> or PCB layout software. Currently, you can find many open-source applications such as PCB Wizard to help you with this task. The next step is cutting the copper board and transferring the PCB print onto the copper layer. To make this process more relatable below is a highlight or outline of the steps:</p>



<ul class="wp-block-list"><li><strong>Design Schematics</strong> – With the aid of <a href="https://tutorial45.com/the-most-popular-cad-software/">CAD software</a>, you can easily design your own schematics or borrow one from the public library of the app you chose.</li><li><strong>Take a Printout of Your <a href="https://tutorial45.com/understanding-the-different-types-of-circuit-boards/">Circuit Board</a> Layout </strong>– The print out should be taken using an A4 photo paper. When doing this, ensure you select a black output so the print out is in black ink. Also, ensure the print is done on the glossy surface of the A4 paper.</li><li><strong>Cut-out Copper Board </strong>– The next step is getting your board. This board should fit the layout and can be cut using a cutter or hacksaw. The surface of the copper board should also be smoothed with an abrasive sponge. This will allow the designed schematics on the printout stick with ease.</li><li><strong>Transfer Printout Onto the Board</strong> – Finally, you can now transfer the schematics onto the board using any of the three techniques outlined in the beginning. How to accomplish this will also be discussed in the next section.</li></ul>



<h3 class="wp-block-heading">Designing Techniques: Iron on Glossy Paper</h3>



<p class="wp-block-paragraph">The Iron on glossy paper technique for etching printout onto the <a href="https://tutorial45.com/understanding-the-different-types-of-circuit-boards/">circuit board</a> is generally applied for complex designs. The process starts by placing the copper plate you cut onto the A4 paper. Ensure the paper and plate is held in place with tape. When doing the placement, it is important to ensure the correct alignment you require is achieved.</p>



<p class="wp-block-paragraph">The second step to take is where your iron will be necessary. By iron, I mean an actual electric iron for clothing. Now, place the board and the taped A4 paper on a flat surface. The arranged plate must be placed in such a way that the back of the A4 paper faces you while its front is pressed onto the copper plate. Before applying the heated iron, some protective or safety measure must be put in place. This includes the wearing of gloves and having a handling device—plier or spatula—by your side.</p>



<p class="wp-block-paragraph">Next, hold one end of the copper plate/A4 paper arrangement and apply the iron to the other end for approximately 10 seconds. Continue to switch ends and iron the entire surface for 10 minutes. You should also apply some pressure while ironing for maximum effect. At the end of this exercise, the heat from the iron should transfer the ink from the glossy A4 paper to the copper plate. But your job is not yet complete. You still have to remove the paper from the copper plate. To do this, place the copper plate arrangement into lukewarm water for 5 to 10 minutes. This would soften the paper and allows you to peel it from its anchor. Once this is done, you will have your printed copper plate.</p>



<p class="wp-block-paragraph">Note that if some of the artwork is faint when ink is transferred to the copper plate. You can strengthen the ink outline by using a blue marker.</p>



<h3 class="wp-block-heading">Designing Circuit Boards by Hand</h3>



<p class="wp-block-paragraph">The next method you can use to stamp your schematic design on the copper plate is drafting by hand. In this method, you can use a pencil to sketch the circuit on the copper plate. Then proceed to strengthen your sketch with a permanent marker. If you are not so good at sketches, you can also attempt tracing the circuit design onto the plate. Simply place the A4 sheet over the plate and use a lead pencil to trace.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="DIY PCB Toner Transfer (No Heat) &amp; Etching" width="800" height="450" src="https://www.youtube.com/embed/cVhSCEPINpM?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Once this is accurately done, you will have your circuit schematic on the copper plate. This is the best method for simple or small circuit designs. As you must have noted, tracing simple schematics reduces the possibility of making any errors.</p>



<h3 class="wp-block-heading">Designing Circuit Boards Using Lasers</h3>



<p class="wp-block-paragraph">The third method involves the use of lasers to etch schematic designs onto a copper plate. In this case, the laser sintering machine used is usually programmed to trace your schematic diagram on the copper plate. This is obviously a faster method of doing things and it is used in industrial factories. Therefore, the use of a laser is a commercial process and it is applied by most PCB businesses to mass-produce <a href="https://tutorial45.com/understanding-the-different-types-of-circuit-boards/">circuit boards</a>.</p>



<p class="wp-block-paragraph">Now that the three methods, for getting your schematic design on the copper plate have been discussed, the next step is etching the PCB board and the schematic drawing on it. Here, an etching fluid or solution is used. This solution is ferric chloride solution (FeCl3) which must be handled with care.</p>



<h3 class="wp-block-heading">Etching the PCB</h3>



<p class="wp-block-paragraph">The etching process involves placing the copper plate into a solution of FeCl3. Therefore, the process is kick-started by having your equipment in place. Hand gloves for safe handling, a bucket or can for mixing the solution and pliers for handling the submerged copper plate.</p>



<p class="wp-block-paragraph">Now, fill up the plastic bucket or can with water. Put in 2 -3 teaspoons of FeCl3 into the water and wait till it dissolves. The copper plate can now be dipped into the solution. It should be left submerged for 30 minutes. During this time, the FeCl3 solution will react with the unmasked copper and remove all the unwanted copper from the PCB. This removal of copper is what is actually termed etching.</p>



<p class="wp-block-paragraph">Once the 30 minutes are up, the pliers should be used to remove the copper plate from the solution. You are expected to observe the etching pattern and if it isn’t complete, submerge the copper plate for more minutes inside the solution. You can now rinse the copper plate with care and leave it out to dry. It is important that the FeCl3 solution is properly disposed of. To do this, further, dilute it by adding a lot more water and throw it at a safe place. Note that, your sink/plumbing, streams, and rivers are not safe places because the solution can damage plumbing and poison aquatic animals.</p>



<h3 class="wp-block-heading">Post-processing the Copper Plate</h3>



<p class="wp-block-paragraph">Once the etching process is complete, the next step is planning how to integrate components on the board. If you intend to use through-hole mounts, then you will require a PCB drilling tool. The PCB driller should be used to make neat holes on the board according to your schematics. If you are partial to colour and want your PCB green, apply solder-resistant green paint before the soldering process.</p>



<p class="wp-block-paragraph">Once the through- holes have been made, you can now integrate your capacitors, transistors, <a href="https://tutorial45.com/electronic-project-diy-led-emergency-light/">LED lights</a>, and inductors in place. Once this is done, you will have your own functional PCB in your hands. You can then proceed with your <a href="https://tutorial45.com/electronic-project-diy-electronic-clock/">electronics project</a> whenever you choose. Note that these basic principles also apply when designing an 8 or 16 layer PCB. All you have to do is be meticulous with your approach.</p>



<h2 class="wp-block-heading">Summary</h2>



<p class="wp-block-paragraph">The process of <a href="https://tutorial45.com/best-pcb-design-software-for-electrical-engineers/">designing a PCB</a> is one that needs some practice. Therefore, with more practice comes better execution. But for many electronics enthusiasts, these processes are time-consuming and may be too technical. This is why it is advisable to simply purchase the PCB of your choice the moment you need one. It is also possible to request a PCB to be fabricated according to your own schematics. You can contact us today to learn more about how we can help.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/understanding-the-basics-of-printed-circuit-boards-the-designing-components-and-construction/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DIY Electronic Fidget Spinner</title>
		<link>https://tutorial45.com/diy-electronic-fidget-spinner/</link>
					<comments>https://tutorial45.com/diy-electronic-fidget-spinner/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Nikodem Bartnik]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 21:31:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">https://tutorial45.com/?p=7527</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/diy-electronic-fidget-spinner/">DIY Electronic Fidget Spinner</a></p>
<p>Let&#8217;s revive our old friend the fidget spinner!. It won&#8217;t be a bad idea if we decide to add a&#160;few LEDs to a fidget spinner shape printed board. Here is the list of all component we are going to use in this DIY project. This kit comes with clear instructions on how to put the ... </p>
<p class="read-more-container"><a title="DIY Electronic Fidget Spinner" class="read-more button" href="https://tutorial45.com/diy-electronic-fidget-spinner/#more-7527" aria-label="More on DIY Electronic Fidget Spinner">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/diy-electronic-fidget-spinner/">DIY Electronic Fidget Spinner</a></p>

<p class="wp-block-paragraph">Let&#8217;s revive our old friend the fidget spinner!. It won&#8217;t be a bad idea if we decide to add a&nbsp;few LEDs to a fidget spinner shape printed board.</p>



<p class="wp-block-paragraph">Here is the list of all component we are going to use in this DIY project.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00055.jpg" alt="diy fidget spinner components" class="wp-image-7528" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00055.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00055-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00055-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00055-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">This kit comes with clear instructions on how to put the parts together.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00057.jpg" alt="diy fidget spinner documentation" class="wp-image-7529" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00057.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00057-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00057-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00057-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">First,&nbsp;we will solder both integrated circuits, there is a mark on the PCB and on the package&nbsp;of those IC. Make sure that those two line up together.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00058.jpg" alt="diy fidget spinner" class="wp-image-7530" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00058.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00058-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00058-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00058-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">There is a place for three resistors next to both ICs. Let&#8217;s put it in place. Those&nbsp;should be labeled 201.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00060.jpg" alt="diy fidget spinner" class="wp-image-7531" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00060.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00060-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00060-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00060-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Between the IC and resistors, we will solder all of the LEDs. Make sure that the green labels on each&nbsp;LED match the vertical line next to LED pad on the PCB.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00061.jpg" alt="diy fidget spinner" class="wp-image-7532" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00061.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00061-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00061-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00061-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">On the third arm of the PCB, we have to solder one resistor and a button.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00062.jpg" alt="diy fidget spinner" class="wp-image-7533" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00062.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00062-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00062-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00062-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Rotate the PCB and put the battery holders in place.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00063.jpg" alt="diy fidget spinner" class="wp-image-7534" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00063.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00063-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00063-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00063-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Turn the PCB upside down and solder all them. That’s the last thing to solder.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00064.jpg" alt="diy fidget spinner" class="wp-image-7535" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00064.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00064-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00064-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00064-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Now we can take off the protective foil from all of the acrylic parts.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00065.jpg" alt="diy fidget spinner" class="wp-image-7536" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00065.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00065-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00065-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00065-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">And we can assemble the frame of our spinner. For that, we have to use the acrylic parts and few&nbsp;screws. The whole assembly process is well explained in the instruction&nbsp;manual.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00066.jpg" alt="diy fidget spinner" class="wp-image-7537" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00066.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00066-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00066-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00066-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">And there you go!</p>



<p class="wp-block-paragraph">That was a quick one, but that thing can sit on your office table making you proud of your accomplishment&nbsp;everytime you look at it.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00067.jpg" alt="diy fidget spinner" class="wp-image-7538" srcset="https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00067.jpg 800w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00067-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00067-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2019/01/DIY-Spinner-DSC00067-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/diy-electronic-fidget-spinner/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Electronic Project for Beginners: Fiber Light</title>
		<link>https://tutorial45.com/electronic-project-for-beginners-fiber-light/</link>
					<comments>https://tutorial45.com/electronic-project-for-beginners-fiber-light/#disqus_thread</comments>
		
		<dc:creator><![CDATA[Nikodem Bartnik]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 21:21:00 +0000</pubDate>
				<category><![CDATA[Electronics and DIY]]></category>
		<guid isPermaLink="false">http://tutorial45.com/?p=6994</guid>

					<description><![CDATA[<p><a href="https://tutorial45.com/electronic-project-for-beginners-fiber-light/">Electronic Project for Beginners: Fiber Light</a></p>
<p>These days everyone wants faster internet, but copper wires reached their limit so we are&#160;using something better than copper. That’s fiber! In this simple DIY project you will see how&#160;light travels through a fiber cable. There are just 4 connections to be soldered in this project making it friendly and perfect for beginners. Here are ... </p>
<p class="read-more-container"><a title="Electronic Project for Beginners: Fiber Light" class="read-more button" href="https://tutorial45.com/electronic-project-for-beginners-fiber-light/#more-6994" aria-label="More on Electronic Project for Beginners: Fiber Light">Read more</a></p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://tutorial45.com/electronic-project-for-beginners-fiber-light/">Electronic Project for Beginners: Fiber Light</a></p>

<p class="wp-block-paragraph">These days everyone wants faster internet, but copper wires reached their limit so we are&nbsp;using something better than copper. That’s fiber! In this simple DIY project you will see how&nbsp;light travels through a fiber cable. There are just 4 connections to be soldered in this project making it friendly and perfect for beginners.</p>



<p class="wp-block-paragraph">Here are the components included in this kit.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00068.jpg" alt="electronic lamp project for beginners" class="wp-image-6995" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00068.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00068-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00068-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00068-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Let’s now start building.</p>



<p class="wp-block-paragraph">We will start with soldering the 2 cables to the LED. Solder the red cable to the longer leg of the LED and the blue cable to the&nbsp;shorter one.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00071.jpg" alt="electronic lamp project for beginners" class="wp-image-6996" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00071.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00071-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00071-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00071-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">We have to solder the LED to the battery holder. Make sure to solder the&nbsp;red cable to the&nbsp;positive of the battery holder and the blue cable to the negative as I mentioned in the previous step.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00073.jpg" alt="electronic lamp project for beginners" class="wp-image-6997" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00073.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00073-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00073-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00073-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">And that’s the end of soldering for today.</p>



<p class="wp-block-paragraph">Let’s construct the&nbsp;frame.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00074.jpg" alt="electronic lamp project for beginners" class="wp-image-6998" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00074.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00074-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00074-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00074-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">We have to connect those together with pieces of a double-sided tape to create the object in the image below.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00076.jpg" alt="electronic lamp project for beginners" class="wp-image-6999" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00076.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00076-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00076-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00076-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Make sure that the hole is on the top. Put a pin in the hole.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00077.jpg" alt="electronic lamp project for beginners" class="wp-image-7000" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00077.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00077-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00077-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00077-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">Grab the&nbsp;orange tube and put the fiber cables in it from the top side and then insert the LED from the bottom. Push&nbsp;that tube on the pin, be careful to not damage the LED.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00079.jpg" alt="electronic lamp project for beginners" class="wp-image-7001" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00079.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00079-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00079-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00079-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00082.jpg" alt="electronic lamp project for beginners" class="wp-image-7002" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00082.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00082-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00082-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00082-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="600" src="http://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00084.jpg" alt="electronic lamp project for beginners" class="wp-image-7003" srcset="https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00084.jpg 800w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00084-300x225.jpg 300w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00084-768x576.jpg 768w, https://tutorial45.com/wp-content/uploads/2018/04/Electronic-project-beginners-DSC00084-320x240.jpg 320w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p class="wp-block-paragraph">And here we go!</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="DIY electronic project: Fiber lamp" width="800" height="450" src="https://www.youtube.com/embed/wgdWItJNfD8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://tutorial45.com/electronic-project-for-beginners-fiber-light/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: tutorial45.com @ 2026-08-12 06:59:17 by W3 Total Cache
-->