วันอังคารที่ 2 ธันวาคม พ.ศ. 2557

Arduino Uno and LCD TC1602A


พอดีวันนี้เกิดอารมณ์ว่างๆก็เลยเห็นจอ LCD   TC1602A  16*2 วางอยู่ไม่ได้ใช้งานเลยนึกสนุกจับใส่ กันลองดูให้มันเกิดไปวิ่งเป็นตัวอักษรขึ้นนั่นเองนะครับ  สำหรับใครว่างๆก็ลองทำดูนะครับ
..ลองมาดูขั้นตอนการทำเลยนะครับ ...

อุปกรณ์ที่ต้องเตรียม

1.เเน่นอนครับ บอร์ด Arduino Uno 1 บอรด
2. หน้าจอ LCD TC1602A
3. สายไฟต่อวงจร
4. ตัวต้านทานประมาณ 20-100 โอห์ม


การต่อวงจร ต่อตามนี้เลยนะครับ





















ซึ่งฝั่งซ้ายคือ ขา LCD ฝั่งขวา คือ arduino  pin นั่นเอง
โดยถ้าเราสังเกตที่ตารางนะครับ  ที่ขา 3 และ ขา 15 ของ LCD จะต้องมี ตัวต้านทานลิมิตเเรงดันไว้นะครับ   คือเอาไว้ปรับความสว่างหน้าจอนั่นเอง โดยใช้ตัวต้านทานประมาณ 40 โอหมก็ ได้นะโดยต่อ   แบบ อนุกรมนะครับ















เมื่อต่อวงจรเสร็จเเล้วนะครับ ก็อัปโหลดโค๊ตลงบอร์ด arduino ได้เลย นะครับ ตัวหนังสือก็จะวิ่ง ตามที่เราเขียนโปรเเกรมไว้นั่นเอง อันนี้ง่ายๆๆนะครับ เพื่อนๆลองทำดู
สำหรับโค๊ตโปรเเกรม ก๊อปด้านล่างเลยครับ
/////
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;    // pin 13 will control the backlight

void setup()
{
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Hello, World");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("kkclap & srv lap");

  // if you have a 4 row LCD, uncomment these lines to write to the bottom rows
  // and change the lcd.begin() statement above.
  //lcd.setCursor(0,2);         // set cursor to column 0, row 2
  //lcd.print("Row 3");
  //lcd.setCursor(0,3);         // set cursor to column 0, row 3
  //lcd.print("Row 4");
  delay(15000);
}

void loop()
{

 
  lcd.clear();
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.                 // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Hi My name");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("keattisak kkm");
  delay(10000);
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Study at kkc ");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("RMUTI khonkean");
  delay(10000);
  lcd.clear();
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("keattisak80@gmail.com  ");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("www.rfthailand.com");
  delay(10000);

}
///////

vdo ตัวอย่างที่เสร็จเเล้วนะครับ 



อ้างอิงจาก 
http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html

วันอาทิตย์ที่ 14 กรกฎาคม พ.ศ. 2556

เปิด_ ปิด LED ผ่าน Bluetooth modul กับ Bluetooth Pc arduino


ขั้นตอน

    อุปกรณ์ที่ใช้  
        -   Arduino Uno 1 บอร์ด
        -   Bluetooth Modul 
        -   ตัวต้านทาน 220 Ohm
        -  สายจั้มต่อ
        -  LED 1 หลอด
         - บอร์ดทดลอง


1.  ต่อวงจรตามรูป



 

รูปเเสดงการต่อวงจร

2.   เขียนโปรเเกรมลงเเละ เบิร์นลง  arduino  ซึ่งโค๊ดก็ตามด้านล่างเลยครับ 


code for arduino


char INBYTE;
int  LED = 7; // LED on pin 7

void setup() {
  Serial.begin(9600); 
  pinMode(LED, OUTPUT);
}

void loop() {
  Serial.println("Press 1 to turn Arduino pin 7 LED ON or 0 to turn it OFF:");
  while (!Serial.available());                                         // stay here so long as COM port is empty   
  INBYTE = Serial.read();                                          // read next available byte
  if( INBYTE == '0' ) digitalWrite(LED, LOW);              // if it's a 0 (zero) tun LED off
  if( INBYTE == '1' ) digitalWrite(LED, HIGH);             // if it's a 1 (one) turn LED on
  delay(50);
}

หลักการทำงานคือเมื่อ  ซีเรียลพอรตอ่าน เจอ 1 หลอด  LED จะสว่าง
เจอ 0  จะดับ  

3.  ตั้งค่าบลูทูธ  ให้ผ่าน serail port  ผมใช้ โปรเเกรม Tera Term เเล้วก็คอนเน็ค ให้ตรงกันกับ บลูทูธ
เเล้วเปิดโปรเเกรม


เลือก comport



ทดสอบ

ดูตัวอย่าง vdo






ถ้าผิดพลาดประการไดก็ขออภัยมา  ณ ที่นี้ด้วยนะครับ