รหัสสินค้า | A00242 |
หมวดหมู่ | IC IO/Driver |
ราคา | 20.00 บาท |
บาร์โค้ด | 88500422 |
สถานะสินค้า | พร้อมส่ง |
สภาพ | สินค้าใหม่ |
ลงสินค้า | 12 ม.ค. 2563 |
อัพเดทล่าสุด | 12 ม.ค. 2563 |
คงเหลือ | ไม่จำกัด |
จำนวน | ชิ้น |
ถ้าขาของ Arduino มีแค่ 3 ขา แล้วอยากรับอินพุต 200 ตัว ซึ่งจะต้องใช้ขา Arduino จำนวน 200 ขา
เพื่อควบคุม แน่นอนว่าขาไม่พอ แล้วจะสั่งควบคุมได้อย่างไร IC ตัวนี้คือคำตอบที่ขอแนะนำ
IC ชิฟรีจิสเตอร์ ใช้ขยายขาอินพุต สามารถต่อพ่วงกันหลาย ๆ ตัวได้ ใช้สัญญาณควบคุมแค่ 3 เส้น ใช้ง่าย
มีโคดสำเร็จรูปให้ใช้งาน
________________________________________________________________________________________________
ตัวอย่างการใช้งาน
ใช้ Resistor 10 k ohm
________________________________________________________________________________________________
ตัวอย่าง Code
/*
* SN74HC165N_shift_reg
*
* Program to shift in the bit values from a SN74HC165N 8-bit
* parallel-in/serial-out shift register.
*
* This sketch demonstrates reading in 16 digital states from a
* pair of daisy-chained SN74HC165N shift registers while using
* only 4 digital pins on the Arduino.
*
* You can daisy-chain these chips by connecting the serial-out
* (Q7 pin) on one shift register to the serial-in (Ds pin) of
* the other.
*
* Of course you can daisy chain as many as you like while still
* using only 4 Arduino pins (though you would have to process
* them 4 at a time into separate unsigned long variables).
*
*/
/* How many shift register chips are daisy-chained.
*/
#define NUMBER_OF_SHIFT_CHIPS 1
/* Width of data (how many ext lines).
*/
#define DATA_WIDTH NUMBER_OF_SHIFT_CHIPS * 8
/* Width of pulse to trigger the shift register to read and latch.
*/
#define PULSE_WIDTH_USEC 5
/* Optional delay between shift register reads.
*/
#define POLL_DELAY_MSEC 500
/* You will need to change the "int" to "long" If the
* NUMBER_OF_SHIFT_CHIPS is higher than 2.
*/
#define BYTES_VAL_T unsigned int
int ploadPin = 8; // Connects to Parallel load pin the 165
int clockEnablePin = 9; // Connects to Clock Enable pin the 165
int dataPin = 11; // Connects to the Q7 pin the 165
int clockPin = 12; // Connects to the Clock pin the 165
BYTES_VAL_T pinValues;
BYTES_VAL_T oldPinValues;
/* This function is essentially a "shift-in" routine reading the
* serial Data from the shift register chips and representing
* the state of those pins in an unsigned integer (or long).
*/
BYTES_VAL_T read_shift_regs()
{
long bitVal;
BYTES_VAL_T bytesVal = 0;
/* Trigger a parallel Load to latch the state of the data lines,
*/
digitalWrite(clockEnablePin, HIGH);
digitalWrite(ploadPin, LOW);
delayMicroseconds(PULSE_WIDTH_USEC);
digitalWrite(ploadPin, HIGH);
digitalWrite(clockEnablePin, LOW);
/* Loop to read each bit value from the serial out line
* of the SN74HC165N.
*/
for(int i = 0; i < DATA_WIDTH; i++)
{
bitVal = digitalRead(dataPin);
/* Set the corresponding bit in bytesVal.
*/
bytesVal |= (bitVal << ((DATA_WIDTH-1) - i));
/* Pulse the Clock (rising edge shifts the next bit).
*/
digitalWrite(clockPin, HIGH);
delayMicroseconds(PULSE_WIDTH_USEC);
digitalWrite(clockPin, LOW);
}
return(bytesVal);
}
/* Dump the list of zones along with their current status.
*/
void display_pin_values()
{
Serial.print("Pin States:\r\n");
for(int i = 0; i < DATA_WIDTH; i++)
{
Serial.print(" Pin-");
Serial.print(i);
Serial.print(": ");
if((pinValues >> i) & 1)
Serial.print("HIGH");
else
Serial.print("LOW");
Serial.print("\r\n");
}
Serial.print("\r\n");
}
void setup()
{
Serial.begin(9600);
/* Initialize our digital pins...
*/
pinMode(ploadPin, OUTPUT);
pinMode(clockEnablePin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
digitalWrite(clockPin, LOW);
digitalWrite(ploadPin, HIGH);
/* Read in and display the pin states at startup.
*/
pinValues = read_shift_regs();
display_pin_values();
oldPinValues = pinValues;
}
void loop()
{
/* Read the state of all zones.
*/
pinValues = read_shift_regs();
/* If there was a chage in state, display which ones changed.
*/
if(pinValues != oldPinValues)
{
Serial.print("*Pin value change detected*\r\n");
display_pin_values();
oldPinValues = pinValues;
}
delay(POLL_DELAY_MSEC);
}
________________________________________________________________________________________________
ข้อมูลเพิ่มเติม IC 74hc165 DIP
ตัวอย่างวีดีโอ IC 74hc165 DIP
บทความสอนใช้งาน Arduino IC 74HC165
หลังจากสั่งซื้อแล้ว กรุณาชำระเงิน และจะต้องแจ้งชำระเงินทางหน้าเวปเท่านั้น (การแจ้งทาง SMS หรือ email ไม่ถือว่าเป็นการแจ้งชำระเงิน) ถ้าไม่มีการแจ้งชำระเงินภายใน 48 ชม. ระบบจะยกเลิกคำสั่งซื้อโดยอัตโนมัติ ถ้าท่านต้องการสั่งซื้อสินค้าอยู่ จะต้องทำการสั่งซื้อใหม่อีกครั้ง
รายการที่แจ้งชำระเงินก่อนเวลา 13:00น. จะทำการจัดส่งในวันทำการเดียวกัน รายการที่แจ้งชำระเงินหลัง 13:00น. จะจัดส่งในวันทำการถัดไป โดยจะทำการจัดส่งทุกวัน จันทร์-ศุกร์ และวันหยุด เป็นบางวัน ตามที่ผู้ขายสะดวก
แจ้งโอนเงินก่อน 9.00 วันเสาร์ส่งวันเสาร์
หลังจากชำระเงินแล้ว คลิ๊กที่นี่ เพิ่อแจ้งชำระเงินทันที โดยไม่ต้องโทรมาแจ้งอีก ถ้าไม่สะดวก ไม่ต้องแนบหลักฐานการโอนก็ได้ แต่กรุณาแจ้งธนาคาร และเวลาที่โอนที่ถูกต้อง จะได้ตรวจสอบได้ครับ
หน้าที่เข้าชม | 43,202 ครั้ง |
ผู้ชมทั้งหมด | 24,165 ครั้ง |
เปิดร้าน | 17 ก.ย. 2559 |
ร้านค้าอัพเดท | 1 ก.ย. 2568 |