วันศุกร์ที่ 27 มกราคม พ.ศ. 2560

801S Vibration Sensor vibration module โมดูลตรวจจับความสันไหวปรับความไวได้

801S Vibration Sensor vibration module โมดูลตรวจจับความสันไหวปรับความไวได้

Vibration Sensor Module ใช้เซนเซอร์เบอร์ 801S ในการตรวจจับความเคลื่อนไหว

คุณภาพสูง ใช้ไฟเลี้ยง3-5V

สามารถปรับความไวได้ ให้สัญญาณanalog และ digital ใช้กับงานตรวจจับ เช่น อุปกร์ป้องกันขโมย,บอร์ดล็อกแบบอิเล็กทรอนิกส์ 
,อุปกรณ์ตรจจับความสั่นไหว





ตัวอย่างการใช้งาน

เซนเซอร์ -> Arduino

+5V -> 5V

Gnd -> Gnd

Output -> A0

 ตัวอย่าง Code

void setup() {

  // initialize serial communication at 9600 bits per second:

  Serial.begin(9600);

}

// the loop routine runs over and over again forever:

void loop() {

  // read the input on analog pin 0:

  int sensorValue = analogRead(A0);

  // print out the value you read:

  Serial.println(sensorValue);

  delay(1000);        // delay in between reads for stability

}

 ตัวอย่าง VDO

https://www.youtube.com/watch?v=7FkL_tyRbQA


อ้างอิง

www.myarduino.net/product/34/801s-vibration-sensor-vibration-module-โมดูลตรวจจับความสันไหวปรับความไวได้

วันพฤหัสบดีที่ 19 มกราคม พ.ศ. 2560

โมดูลสื่อสารไร้สายระยะสั้น

PN532 NFC RFID V3



รายละเอียด
 PN532 NFC RFID Module เป็นโมดูลสื่อสารไร้สายระยะสั้นระยะประมาณ 4 ซม. ที่ใช้ได้ดีกับโครงสร้างพื้นฐานแบบไร้สัมผัส ช่วยสนับสนุนรองรับการสื่อสารระหว่างเครื่องมืออิเล็กทรอนิกส์ในระยะใกล้ๆ รองรับการใช้งานแบบ II2, SPI และ HSU (High Speed UART) ใช้ไฟเลี้ยง 5V 


ประกอบด้วย
Items Quantity
PN532 NFC RFID Module 1
2.54 mm spacing 4pin Cable 1
Mifare One S50 White Card 1
Mifare One S50 Key Card 1
12P bended male pins


การต่อวงจร
Vcc - > 3.3 / 5 V
Gnd -> Gnd
SCL -> A5
SDA -> A4


โค้ดตัวอย่างการใช้งาน

#include

#include <PN532_I2C.h>

#include

PN532_I2C pn532i2c(Wire);

PN532 nfc(pn532i2c);

void setup(void)

{

  Serial.begin(115200);

  Serial.println("Hello!");

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();

  if (! versiondata)

 {

    Serial.print("Didn't find PN53x board");

    while (1); // halt

  }

  

  // Got ok data, print it out!

  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 

  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 

  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

  

  // Set the max number of retry attempts to read from a card

  // This prevents us from waiting forever for a card, which is

  // the default behaviour of the PN532.

  nfc.setPassiveActivationRetries(0xFF);

  // configure board to read RFID tags

  nfc.SAMConfig();

  Serial.println("Waiting for an ISO14443A card");

}


void loop(void)

{

  boolean success;

  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID

  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  

  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found

  // 'uid' will be populated with the UID, and uidLength will indicate

  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)

  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);

  

  if (success)

    {

    Serial.println("Found a card!");

    Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");

    Serial.print("UID Value: ");

    for (uint8_t i=0; i < uidLength; i++) 

    {

      Serial.print(" 0x");Serial.print(uid[i], HEX); 

    }

    Serial.println("");

    // Wait 1 second before continuing

    delay(1000);

  }

  else

  {

    // PN532 probably timed out waiting for a card

    Serial.println("Timed out waiting for a card");

  }

}

หน้าจอแสดงผลขณะยังไม่แตะ PN532 NFC RFID 


หน้าจอแสดงผลขณะแตะ PN532 NFC RFID 


อ้างอิง

 https://www.arduinoall.com/product/146/rfid-nfc-module-kit-pn532-พร้อมแท็ก-2-ชิ้น-card-พวงกุญแจ

วันเสาร์ที่ 14 มกราคม พ.ศ. 2560

JoyStick Shield expansion board for arduino

JoyStick Shield expansion board for arduino

     จอยสติกสำหรับ Arduino แค่เสียบลงไป ก็สมารถใช้ Arduino ควบคุมเป็นแบบ JoyStick ได้แล้ว  ใช้งานง่ายเหมือนเป็นสวิตช์ทั่ว ๆ ไป พร้อมช่องรองรับการเชื่อมต่อแบบไร้สาย NRF24L01 และจอแสดงผล Nokia 5110 LCD

รายละเอียด JoyStick Shield expansion board for arduino

  Add nRF24L01 RF interface
  Add Nokia 5110 LCD interface, so very easy to game development.
  Adding a Bluetooth module interface, convenient Bluetooth wireless serial communication.
  Add I2C communication interface, easy connectivity to I2C devices
  Meanwhile, JoyStick Shield with a cross PS2 joystick with buttons, there are four round buttons, 2     small buttons.
  Provides for the Arduino joystick and buttons input expansion. Onboard switches can switch          b   between 3.3V and 5V, can use this model for other 3.3V microcontroller platforms, such as STM32.

  Map ขา nRF24L01

   MOSI = D11
   CSN = D10
   VCC = 3V
   MISO = D12
   SCK = D13
   CE = D9

ตัวอย่างโคด Arduino JoyStick Shield expansion board for arduino

const byte PIN_ANALOG_X = 0;
const byte PIN_ANALOG_Y = 1;
const byte PIN_A = 2;
const byte PIN_B = 3;
const byte PIN_C = 4;
const byte PIN_D = 5;
const byte PIN_E = 6;
const byte PIN_F = 7;
const byte PIN_K = 8;


void setup() {
  Serial.begin(9600);

  pinMode(PIN_A, INPUT);
  digitalWrite(PIN_A, HIGH);

  pinMode(PIN_B, INPUT);
  digitalWrite(PIN_B, HIGH);

  pinMode(PIN_C, INPUT);
  digitalWrite(PIN_C, HIGH);

  pinMode(PIN_D, INPUT);
  digitalWrite(PIN_D, HIGH);

  pinMode(PIN_E, INPUT);
  digitalWrite(PIN_E, HIGH);
  
  pinMode(PIN_F, INPUT);
  digitalWrite(PIN_F, HIGH);
  
  pinMode(PIN_K, INPUT);
  digitalWrite(PIN_K, HIGH);
}

void loop() {
  Serial.print("x:");
  Serial.print(analogRead(PIN_ANALOG_X));
  Serial.print(" ");

  Serial.print("y:");
  Serial.print(analogRead(PIN_ANALOG_Y));
  Serial.print(" ");
  
  Serial.print("A:");
  Serial.print(digitalRead(PIN_A));
  Serial.print(" ");

  Serial.print("B:");
  Serial.print(digitalRead(PIN_B));
  Serial.print(" ");

  Serial.print("C:");
  Serial.print(digitalRead(PIN_C));
  Serial.print(" ");

  Serial.print("D:");
  Serial.print(digitalRead(PIN_D));
  Serial.print(" ");

  Serial.print("E:");
  Serial.print(digitalRead(PIN_E));
  Serial.print(" ");
  
  Serial.print("F:");
  Serial.print(digitalRead(PIN_F));
  Serial.print(" ");
  
  Serial.print("K:");
  Serial.print(digitalRead(PIN_K));
  Serial.print(" ");


  Serial.println();
}

วีดีโอตัวอย่าง Arduino JoyStick Shield expansion board for arduino

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




วันอังคารที่ 3 มกราคม พ.ศ. 2560

GP2Y0A02 Infrared Sensor Sharp GP2Y0A02 Distance Sensor 20cm - 150cm

เซนเซอร์วัดระยะทางเป็นเส้นตรงด้วยอินฟาเรด ระยะทางแม่นยำ 20 - 150 เซนติเมตร

รายละเอียด Distance Measuring Sensor 20-150cm (SHARP GP2Y0A02)

Technical / Catalog Information GP2Y0A02
Classification Sensors, Transducers
Analog output type
Range 20cm ~ 150cm
Supply voltage 4.5V ~ 5.5V
Current - 33mA power
Voltage - Output (standard value) @ a distance under the conditions of 400mV @ 150cm
Voltage - difference (standard value) 2.05V @ 20 ~ 150cm
 
ตัวอย่างโคด Arduino Distance Measuring Sensor 20-150cm (SHARP GP2Y0A02)

int IRpin = A0;                               // ต่อเซนเซอร์กับขา A0

void setup() {
   
  Serial.begin(9600);                             
}

void loop() {
  float volts = analogRead(IRpin)*0.0048828125;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  float distance = 65*pow(volts, -1.10);         
  Serial.println(distance);                      
  delay(100);                                     
}