Sunday 23 June 2019

Touch Shield Arduino Uno

Reference website

https://www.youtube.com/watch?v=Js4wykWY6zg

https://www.youtube.com/watch?v=IIQlGHpUZXw


TFT LCD 2.4" Touch screen shield tutorial for beginners

1,061 views
Published on Nov 22, 2018

Touch Screen _Calibr_native,ino uploded then check Serial Monitor




// Paint example specifically for the TFTLCD breakout board.
// If using the Arduino shield, use the tftpaint_shield.pde sketch instead!
// DOES NOT CURRENTLY WORK ON ARDUINO LEONARDO

// Modified for SPFD5408 Library by Joao Lopes
// Version 0.9.2 - Rotation for Mega

// *** SPFD5408 change -- Begin
#include <SPFD5408_Adafruit_GFX.h>    // Core graphics library
#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
#include <SPFD5408_TouchScreen.h>
// *** SPFD5408 change -- End

#if defined(_SAM3X8E_)
    #undef_FlashStringHelper::F(string_literal)
    #define F(String_literal) string_literal
#endif

#define YP A3
#define XM A2
#define YM 9
#define XP 8

#define TS_MINX 125
#define TS_MINY 85
#define TS_MAXX 965
#define TS_MAXY 905

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);


#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
// optional
#define LCD_RESET A4

#define MINPRESSURE 10
#define MAXPRESSURE 1000

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);


void setup(void) {

  tft.reset();
  tft.begin(0x9328);
  tft.setRotation(0);
  tft.fillScreen(BLACK);
  tft.fillRect(20, 40, 80, 80, RED);
  tft.fillRect(130, 40, 80, 80, GREEN);

  pinMode(13, OUTPUT);

}

void loop()
{
  TSPoint p = ts.getPoint();
 
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {

    p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
    p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());;

    if(p.y > 20 && p.y < 100 && p.x >40 && p.x <120){
      tft.fillRect(0, 180, 300, 300, BLACK);
      tft.setCursor(20,180);
      tft.setTextColor(WHITE); tft.setTextSize(3);
      tft.print("Green pressed");
      digitalWrite(13, HIGH);
    }
     else if (p.x > 130 && p.x < 210 && p.y >40 && p.y <120){
      tft.fillRect(0, 180, 300, 300, BLACK);
      tft.setCursor(0,180);
      tft.setTextColor(WHITE); tft.setTextSize(3);
      tft.print("Red pressed");
      digitalWrite(13, LOW);

        
    }
  }
 
}





Wednesday 19 June 2019

Serial Communication String LED On Off

reference website: http://www.chrisbrand.co.za/2013/06/30/arduino-serial-port/



 /*
   Simple LED sketch
   */
 
  int led = 13; // Pin 13
 
  void setup()
  {
      pinMode(led, OUTPUT); // Set pin 13 as digital out

     // Start up serial connection
     Serial.begin(9600); // baud rate
     Serial.flush();
 }

 void loop()
 {
     String input = "";

     // Read any serial input
     while (Serial.available() > 0)
     {
         input += (char) Serial.read(); // Read in one char at a time
         delay(5); // Delay for 5 ms so the next char has time to be received
     }

     if (input == "on")
     {
         digitalWrite(led, HIGH); // on
     }
     else if (input == "off")
     {
         digitalWrite(led, LOW); // off
     }
 }

Wednesday 12 June 2019

HC06 Arduino Uno Bluetooth Password 1234 3.3V input voltage


https://play.google.com/store/apps/details?id=com.circuitmagic.arduinobluetooth&hl=en
https://www.youtube.com/watch?v=OXpIUvYjbN0

https://www.circuitmagic.com/arduino/arduino-and-bluetooth-hc-06-to-control-the-led-with-android-device/


using 3.3 V no need resistor

using 5.0 must resistor


not yet tested https://circuitdigest.com/microcontroller-projects/arduino-based-voice-controlled-leds

HC05 Voice Command Arduino Uno Do Not Put 3.3V

https://www.instructables.com/id/Voice-Activated-Arduino-Bluetooth-Android/