找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
樓主: eagler8
打印 上一主題 下一主題
收起左側(cè)

【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)

  [復(fù)制鏈接]
2081#
ID:513258 發(fā)表于 2019-9-4 08:06 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2082#
ID:513258 發(fā)表于 2019-9-4 08:10 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2083#
ID:513258 發(fā)表于 2019-9-4 08:26 | 只看該作者
主要特點(diǎn)
控制電路和LED共用唯一的電源。
控制電路和RGB芯片集成在5050個(gè)組件的封裝中,形成完整的可尋址像素。內(nèi)置信號(hào)整形電路,對(duì)下一個(gè)驅(qū)動(dòng)器進(jìn)行波形整形后,確保波形不失真累積。
內(nèi)置電氣復(fù)位電路和失電復(fù)位電路。
三基色各像素可實(shí)現(xiàn)256亮度顯示,完成16777216色全彩色顯示,掃描頻率為2kHz。
單線(xiàn)路級(jí)聯(lián)端口傳輸信號(hào)。
任意兩點(diǎn)距離不超過(guò)3米的傳輸信號(hào),無(wú)任何增加電路。
刷新率為30fps時(shí),層疊數(shù)不小于1024像素。以800Kbps的速度發(fā)送數(shù)據(jù)。
燈光顏色一致性高,性?xún)r(jià)比高。

應(yīng)用
全彩模塊,全彩軟燈帶。
LED裝飾照明,室內(nèi)外LED視頻不規(guī)則屏幕。



回復(fù)

使用道具 舉報(bào)

2084#
ID:513258 發(fā)表于 2019-9-4 08:31 | 只看該作者
幾個(gè)應(yīng)用電路




回復(fù)

使用道具 舉報(bào)

2085#
ID:513258 發(fā)表于 2019-9-4 08:41 | 只看該作者


名稱(chēng):12位WS2812智能全彩圓盤(pán)LED模塊
整體尺寸:直徑7cm
芯片:WS2812B(內(nèi)置于LED)
LED:5050封裝RGB全彩高亮
電壓:5V
端口:數(shù)字
平臺(tái):?jiǎn)纹瑱C(jī)(提供Arduino +51單片機(jī)測(cè)試?yán)蹋?
控制方式:內(nèi)置控制芯片,只需一個(gè)IO口即可控制

回復(fù)

使用道具 舉報(bào)

2086#
ID:513258 發(fā)表于 2019-9-4 08:57 | 只看該作者



回復(fù)

使用道具 舉報(bào)

2087#
ID:513258 發(fā)表于 2019-9-4 09:33 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB環(huán)開(kāi)發(fā)板大環(huán)
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索Adafruit_NeoPixel-安裝
  5. 2、項(xiàng)目:點(diǎn)亮環(huán)形LED模塊,循環(huán)快閃綠色光
  6. 3、接腳:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <Adafruit_NeoPixel.h>

  12. #define PIN 7
  13. #define MAX_LED 12

  14. #define ADD true
  15. #define SUB false

  16. int val = 0;
  17. boolean stat = ADD;

  18. Adafruit_NeoPixel strip = Adafruit_NeoPixel( MAX_LED, PIN, NEO_RGB + NEO_KHZ800 );

  19. void setup()
  20. {
  21.   strip.begin();           
  22.   strip.show();           
  23. }

  24. void loop()
  25. {
  26.   uint8_t i,a=0;                                       
  27.   uint32_t color = strip.Color(255, 100, 0);      
  28.      
  29.   while(a<17)
  30.   {
  31.       for(i=0;i<16;i++)
  32.       {
  33.         if(i==a) strip.setPixelColor(i, color);     
  34.         else strip.setPixelColor(i, 0);            
  35.       }
  36.        strip.show();                                
  37.        delay(20);                                   
  38.        a++;                                         
  39.   }
  40. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2088#
ID:513258 發(fā)表于 2019-9-4 09:35 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2089#
ID:513258 發(fā)表于 2019-9-4 11:32 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB環(huán)開(kāi)發(fā)板大環(huán)
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索Adafruit_NeoPixel-安裝
  5. 2、項(xiàng)目:燈環(huán)顯示彩色
  6. 3、接腳:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <Adafruit_NeoPixel.h>
  12. #ifdef __AVR__
  13. #include <avr/power.h>
  14. #endif

  15. #define PIN 7

  16. // Parameter 1 = number of pixels in strip
  17. // Parameter 2 = Arduino pin number (most are valid)
  18. // Parameter 3 = pixel type flags, add together as needed:
  19. //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
  20. //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
  21. //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
  22. //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
  23. //   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
  24. Adafruit_NeoPixel strip = Adafruit_NeoPixel(64, PIN, NEO_GRB + NEO_KHZ800);

  25. // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
  26. // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
  27. // and minimize distance between Arduino and first pixel.  Avoid connecting
  28. // on a live circuit...if you must, connect GND first.

  29. void setup() {
  30.   // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  31.   #if defined (__AVR_ATtiny85__)
  32.     if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  33.   #endif
  34.   // End of trinket special code


  35.   strip.begin();
  36.   strip.show(); // Initialize all pixels to 'off'
  37. }

  38. void loop() {
  39.   // Some example procedures showing how to display to the pixels:
  40.   //colorWipe(strip.Color(255, 0, 0), 50); // Red
  41. // colorWipe(strip.Color(0, 255, 0), 50); // Green
  42.   //colorWipe(strip.Color(0, 0, 255), 50); // Blue
  43. //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
  44.   // Send a theater pixel chase in...
  45. // theaterChase(strip.Color(127, 127, 127), 50); // White
  46.   //theaterChase(strip.Color(127, 0, 0), 50); // Red
  47.   //theaterChase(strip.Color(0, 0, 127), 50); // Blue

  48.   rainbow(20);
  49.   //rainbowCycle(20);
  50.   //theaterChaseRainbow(50);
  51. }

  52. // Fill the dots one after the other with a color
  53. void colorWipe(uint32_t c, uint8_t wait) {
  54.   for(uint16_t i=0; i<strip.numPixels(); i++) {
  55.     strip.setPixelColor(i, c);
  56.     strip.show();
  57.     delay(wait);
  58.   }
  59. }

  60. void rainbow(uint8_t wait) {
  61.   uint16_t i, j;

  62.   for(j=0; j<256; j++) {
  63.     for(i=0; i<strip.numPixels(); i++) {
  64.       strip.setPixelColor(i, Wheel((i+j) & 255));
  65.     }
  66.     strip.show();
  67.     delay(wait);
  68.   }
  69. }

  70. // Slightly different, this makes the rainbow equally distributed throughout
  71. void rainbowCycle(uint8_t wait) {
  72.   uint16_t i, j;

  73.   for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
  74.     for(i=0; i< strip.numPixels(); i++) {
  75.       strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
  76.     }
  77.     strip.show();
  78.     delay(wait);
  79.   }
  80. }

  81. //Theatre-style crawling lights.
  82. void theaterChase(uint32_t c, uint8_t wait) {
  83.   for (int j=0; j<10; j++) {  //do 10 cycles of chasing
  84.     for (int q=0; q < 3; q++) {
  85.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  86.         strip.setPixelColor(i+q, c);    //turn every third pixel on
  87.       }
  88.       strip.show();

  89.       delay(wait);

  90.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  91.         strip.setPixelColor(i+q, 0);        //turn every third pixel off
  92.       }
  93.     }
  94.   }
  95. }

  96. //Theatre-style crawling lights with rainbow effect
  97. void theaterChaseRainbow(uint8_t wait) {
  98.   for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
  99.     for (int q=0; q < 3; q++) {
  100.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  101.         strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
  102.       }
  103.       strip.show();

  104.       delay(wait);

  105.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  106.         strip.setPixelColor(i+q, 0);        //turn every third pixel off
  107.       }
  108.     }
  109.   }
  110. }

  111. // Input a value 0 to 255 to get a color value.
  112. // The colours are a transition r - g - b - back to r.
  113. uint32_t Wheel(byte WheelPos) {
  114.   WheelPos = 255 - WheelPos;
  115.   if(WheelPos < 85) {
  116.     return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  117.   }
  118.   if(WheelPos < 170) {
  119.     WheelPos -= 85;
  120.     return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  121.   }
  122.   WheelPos -= 170;
  123.   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  124. }  
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2090#
ID:513258 發(fā)表于 2019-9-4 11:57 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB環(huán)開(kāi)發(fā)板大環(huán)
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索Adafruit_NeoPixel-安裝
  5. 2、項(xiàng)目:逐個(gè)點(diǎn)亮環(huán)形彩色LED
  6. 3、接腳:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <FastLED.h>
  12. #define LED_PIN     7
  13. #define NUM_LEDS    12

  14. CRGB leds[NUM_LEDS];

  15. void setup() {
  16.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  17. }

  18. void loop() {
  19.   leds[0] = CRGB(255, 0, 0);
  20.   FastLED.show();
  21.   delay(500);  
  22.   
  23.   leds[1] = CRGB(0, 255, 0);
  24.   FastLED.show();
  25.   delay(500);
  26.   
  27.   leds[2] = CRGB(0, 0, 255);
  28.   FastLED.show();
  29.   delay(500);
  30.   
  31.   leds[3] = CRGB(150, 0, 255);
  32.   FastLED.show();
  33.   delay(500);
  34.   
  35.   leds[4] = CRGB(255, 200, 20);
  36.   FastLED.show();
  37.   delay(500);
  38.   
  39.   leds[5] = CRGB(85, 60, 180);
  40.   FastLED.show();
  41.   delay(500);
  42.   
  43.   leds[6] = CRGB(150, 255, 20);
  44.   FastLED.show();
  45.   delay(500);

  46.   leds[7] = CRGB(0, 50, 255);
  47.   FastLED.show();
  48.   delay(500);

  49.   leds[8] = CRGB(255, 255, 0);
  50.   FastLED.show();
  51.   delay(500);  
  52.   
  53.   leds[9] = CRGB(20, 25, 255);
  54.   FastLED.show();
  55.   delay(500);
  56.   
  57.   leds[10] = CRGB(255, 0, 20);
  58.   FastLED.show();
  59.   delay(500);
  60.   
  61.   leds[11] = CRGB(50, 0, 55);
  62.   FastLED.show();
  63.   delay(500);
  64. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2091#
ID:513258 發(fā)表于 2019-9-4 12:56 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB環(huán)開(kāi)發(fā)板大環(huán)
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索Adafruit_NeoPixel-安裝
  5. 2、項(xiàng)目:紅藍(lán)色快掃——這里第一個(gè)“for”循環(huán)點(diǎn)亮所有12個(gè)藍(lán)色LED,
  6. 從第一個(gè)LED到最后一個(gè)LED,延遲40毫秒。 下一個(gè)“for”循環(huán)再
  7. 次點(diǎn)亮所有12個(gè)LED,但這次是紅色,反之,從最后一個(gè)LED到第一個(gè)LED。
  8. 3、接腳:
  9. VCC  → 5V
  10. GND → GND
  11. DI  接  D7
  12. */

  13. #include <FastLED.h>
  14. #define LED_PIN     7
  15. #define NUM_LEDS    12

  16. CRGB leds[NUM_LEDS];

  17. void setup() {
  18.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  19. }

  20. void loop() {
  21.   for (int i = 0; i <= 11; i++) {
  22.     leds[i] = CRGB ( 0, 0, 255);
  23.     FastLED.show();
  24.     delay(60);
  25.   }
  26.   for (int i = 11; i >= 0; i--) {
  27.     leds[i] = CRGB ( 255, 0, 0);
  28.     FastLED.show();
  29.     delay(40);
  30.   }
  31. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2092#
ID:513258 發(fā)表于 2019-9-4 13:05 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB環(huán)開(kāi)發(fā)板大環(huán)
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索Adafruit_NeoPixel-安裝
  5. 2、項(xiàng)目:逐個(gè)點(diǎn)亮不同序列的LED(可設(shè)置為任何顏色)
  6. 3、接腳:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <FastLED.h>
  12. #define LED_PIN     7
  13. #define NUM_LEDS    12

  14. CRGB leds[NUM_LEDS];

  15. void setup() {
  16.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  17. }

  18. void loop() {
  19.   
  20.   leds[0] = CRGB(255, 0, 0);
  21.   FastLED.show();
  22.   delay(500);  
  23.   leds[1] = CRGB(0, 255, 0);
  24.   FastLED.show();
  25.   delay(500);
  26.   leds[2] = CRGB(0, 0, 255);
  27.   FastLED.show();
  28.   delay(500);
  29.   leds[5] = CRGB(150, 0, 255);
  30.   FastLED.show();
  31.   delay(500);
  32.   leds[9] = CRGB(255, 200, 20);
  33.   FastLED.show();
  34.   delay(500);
  35.   leds[3] = CRGB(85, 60, 180);
  36.   FastLED.show();
  37.   delay(500);
  38.   leds[7] = CRGB(50, 255, 20);
  39.   FastLED.show();
  40.   delay(500);
  41. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2093#
ID:513258 發(fā)表于 2019-9-4 14:09 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2094#
ID:513258 發(fā)表于 2019-9-4 14:35 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2095#
ID:513258 發(fā)表于 2019-9-4 20:33 | 只看該作者
37款傳感器與模塊的提法,在網(wǎng)絡(luò)上廣泛流傳,其實(shí)Arduino能夠兼容的傳感器模塊肯定是不止37種的。鑒于本人手頭積累了一些傳感器和模塊,依照實(shí)踐出真知(一定要?jiǎng)邮肿觯┑睦砟,以學(xué)習(xí)和交流為目的,這里準(zhǔn)備逐一動(dòng)手試試做實(shí)驗(yàn),不管成功與否,都會(huì)記錄下來(lái)---小小的進(jìn)步或是搞不定的問(wèn)題,希望能夠拋磚引玉。

【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
實(shí)驗(yàn)一百零六: TM1638按鍵數(shù)碼管LED顯示模組8位數(shù)碼管\LED\按鍵智控模塊





回復(fù)

使用道具 舉報(bào)

2096#
ID:513258 發(fā)表于 2019-9-4 20:36 | 只看該作者

TM1638
是一種帶鍵盤(pán)掃描接口的LED(發(fā)光二極管顯示器)驅(qū)動(dòng)控制專(zhuān)用IC,內(nèi)部集成有MCU數(shù)字接口、數(shù)據(jù)鎖存器、LED驅(qū)動(dòng)、鍵盤(pán)掃描等電路。本模塊質(zhì)量可靠、穩(wěn)定性好、抗干擾能力強(qiáng)。主要應(yīng)用于冰箱、空調(diào) 、家庭影院等產(chǎn)品的高段位顯示屏驅(qū)動(dòng)。

回復(fù)

使用道具 舉報(bào)

2097#
ID:513258 發(fā)表于 2019-9-4 20:47 | 只看該作者

TM1638
1、采用CMOS 工藝
2、顯示模式 10段×8 位
3、鍵掃描(8×3bit)
4、輝度調(diào)節(jié)電路(占空比8 級(jí)可調(diào))
5、串行接口(CLK,STB,DIO)
6、振蕩方式:RC 振蕩
7、內(nèi)置上電復(fù)位電路
8、封裝形式:SOP28

回復(fù)

使用道具 舉報(bào)

2098#
ID:513258 發(fā)表于 2019-9-5 14:44 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2099#
ID:513258 發(fā)表于 2019-9-5 14:52 | 只看該作者



回復(fù)

使用道具 舉報(bào)

2100#
ID:513258 發(fā)表于 2019-9-5 14:54 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2101#
ID:513258 發(fā)表于 2019-9-5 14:56 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2102#
ID:513258 發(fā)表于 2019-9-5 14:57 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2103#
ID:513258 發(fā)表于 2019-9-5 16:43 | 只看該作者

模塊功能介紹
包括以下資源:
1、8個(gè)按鍵,
2、8個(gè)LED
3、8位數(shù)碼管,共陰極LED數(shù)碼管;
4、可以和STC等單片機(jī)直接連接;
5、開(kāi)始實(shí)驗(yàn)ardiuno驅(qū)動(dòng)程序

回復(fù)

使用道具 舉報(bào)

2104#
ID:513258 發(fā)表于 2019-9-5 16:48 | 只看該作者
模塊電原理圖



回復(fù)

使用道具 舉報(bào)

2105#
ID:513258 發(fā)表于 2019-9-5 16:49 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2106#
ID:513258 發(fā)表于 2019-9-5 16:51 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2107#
ID:513258 發(fā)表于 2019-9-5 16:53 | 只看該作者
該模塊所用芯片為T(mén)M1638,集合了單片機(jī)常見(jiàn)外圍電路,最大特點(diǎn)是只需占用單片機(jī)三個(gè)IO口即可驅(qū)動(dòng),掃描顯示和按鍵掃描不需要單片機(jī)干預(yù),只需要讀寫(xiě)相關(guān)寄存器送顯示數(shù)據(jù)或檢測(cè)按鍵,節(jié)省MCU資源。試想下,我們平時(shí)使用單片機(jī)外接8個(gè)LED,8位數(shù)碼管,8個(gè)按鍵這需占用多少個(gè)IO口,遠(yuǎn)不止3個(gè)IO口吧,但用這個(gè)模塊就可以實(shí)現(xiàn)。經(jīng)實(shí)際應(yīng)用,按鍵靈敏顯示效果良好。

接線(xiàn)方法:
VCC GND接5V電源, STB CLK DIO接單片機(jī)IO口。



回復(fù)

使用道具 舉報(bào)

2108#
ID:513258 發(fā)表于 2019-9-5 16:55 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2109#
ID:513258 發(fā)表于 2019-9-5 16:57 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2110#
ID:513258 發(fā)表于 2019-9-5 17:47 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零六: TM1638按鍵數(shù)碼管LED顯示模組8位數(shù)碼管\LED\按鍵智控模塊
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索TM1638plus-安裝
  5. 2、項(xiàng)目:TM1638模塊的演示文件庫(kù)(LED和鍵)
  6. 《作者:加文·萊昂斯(Gavin Lyons)》
  7. 3、接腳:
  8. VCC  → 5V
  9. GND → GND
  10. STROBE_TM  D4
  11. CLOCK_TM   D6
  12. DIO_TM     D7
  13. */

  14. #include <TM1638plus.h>

  15. // GPIO I/O pins on the Arduino connected to strobe, clock, data,
  16. //pick on any I/O you want.
  17. #define  STROBE_TM 4
  18. #define  CLOCK_TM 6
  19. #define  DIO_TM 7

  20. //Constructor object
  21. TM1638plus tm(STROBE_TM, CLOCK_TM , DIO_TM);


  22. void setup() {
  23.    // Test 0 reset test
  24.    tm.setLED(0, 1);
  25.    delay(1000);
  26.    tm.reset();
  27.   
  28.   // Test 1  Brightness and reset
  29.    for (uint8_t brightness = 0; brightness < 8; brightness++)
  30.    {
  31.           tm.brightness(brightness);
  32.           tm.displayText("00000000");
  33.           delay(1500);
  34.    }
  35.    tm.reset();
  36.    
  37.    // restore default brightness
  38.    tm.brightness(0x02);
  39.   
  40.    //Test 2 ASCII display 2.348
  41.    
  42.    tm.displayASCIIwDot(0, '2');
  43.    tm.displayASCII(1, '3');
  44.    tm.displayASCII(2, '4');
  45.    tm.displayASCII(3, '8');
  46.    delay(2000);
  47.   
  48.    //TEST 3 single segment
  49.    //In this case  segment g (middle dash) of digit position 7
  50.    tm.display7Seg(7,0b01000000);
  51.    delay(2000);
  52.    
  53.    // Test 4 Hex digits.
  54.    tm.displayHex(0, 1);
  55.    tm.displayHex(1, 2);
  56.    tm.displayHex(2, 3);
  57.    tm.displayHex(3, 4);
  58.    tm.displayHex(4, 5);
  59.    tm.displayHex(5, 6);
  60.    tm.displayHex(6, 7);
  61.    tm.displayHex(7, 8);
  62.    delay(2000);
  63.    tm.displayHex(0, 8);
  64.    tm.displayHex(1, 9);
  65.    tm.displayHex(2, 10);
  66.    tm.displayHex(3, 11);
  67.    tm.displayHex(4, 12);
  68.    tm.displayHex(5, 13);
  69.    tm.displayHex(6, 14);
  70.    tm.displayHex(7, 15);
  71.    delay(2000);

  72.    // Test 5 TEXT  with dec point
  73.    // abcdefgh with decimal point for c and d
  74.    tm.displayText("abc.d.efgh");
  75.    delay(3000);
  76.    
  77.    // Test6  TEXT + ASCII combo
  78.    // ADC=2.548
  79.    char text1[]= "ADC=.";
  80.    tm.displayText(text1);
  81.    tm.displayASCIIwDot(4, '2');
  82.    tm.displayASCII(5, '5');
  83.    tm.displayASCII(6, '4');
  84.    tm.displayASCII(7, '8');
  85.    delay(2000);
  86.   
  87.    //Test 7 buttons and LED test
  88.    tm.displayText("EAGLER8 ");
  89. }


  90. void loop() {
  91.    uint8_t buttons = tm.readButtons();
  92.    doLEDs(buttons);
  93. }

  94. // scans the individual bits of value
  95. void doLEDs(uint8_t value) {
  96.   for (uint8_t position = 0; position < 8; position++) {
  97.     tm.setLED(position, value & 1);
  98.     value = value >> 1;
  99.   }
  100. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2111#
ID:513258 發(fā)表于 2019-9-5 17:48 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2112#
ID:513258 發(fā)表于 2019-9-5 18:28 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
  3. 實(shí)驗(yàn)一百零六: TM1638按鍵數(shù)碼管LED顯示模組8位數(shù)碼管\LED\按鍵智控模塊
  4. 1、安裝庫(kù):IDE-工具-管理庫(kù)-搜索TM1638-安裝
  5. 2、項(xiàng)目:自鎖LED,按鍵計(jì)數(shù)器
  6. 3、接腳:
  7. VCC  → 5V
  8. GND → GND
  9. STROBE_TM  D4
  10. CLOCK_TM   D6
  11. DIO_TM     D7
  12. */

  13. #define        DATA_COMMAND        0X40
  14. #define        DISP_COMMAND        0x80
  15. #define        ADDR_COMMAND        0XC0

  16. //TM1638模塊引腳定義
  17. int DIO = 7;
  18. int CLK = 6;
  19. int STB = 4; //這里定義了那三個(gè)腳
  20. //共陰數(shù)碼管顯示代碼
  21. unsigned char tab[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,
  22.                            0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};
  23. unsigned char num[8];                //各個(gè)數(shù)碼管顯示的值                     
  24. void setup ()
  25. {
  26.   pinMode(STB,OUTPUT);
  27.   pinMode(CLK,OUTPUT);
  28.   pinMode(DIO,OUTPUT); //讓三個(gè)腳都是輸出狀態(tài)
  29. }
  30. void loop()
  31.     {
  32.         unsigned char i;
  33.         init_TM1638();                                   //初始化TM1638
  34.         for(i=0;i<8;i++)
  35.         Write_DATA(i<<1,tab[0]);                       //初始化寄存器       
  36.         while(1)
  37.         {
  38.                 i=Read_key();                          //讀按鍵值
  39.                 if(i<8)
  40.                 {
  41.                   num[i]++;
  42.                   while(i==Read_key());                       //等待按鍵釋放
  43.                   if(num[i]>15)
  44.                   num[i]=0;
  45.                   Write_DATA(i*2,tab[num[i]]);
  46.                   Write_allLED(1<<i);
  47.                 }
  48.         }
  49. }



  50. void TM1638_Write(unsigned char        DATA)                        //寫(xiě)數(shù)據(jù)函數(shù)
  51. {
  52.         unsigned char i;
  53.         pinMode(DIO,OUTPUT);
  54.         for(i=0;i<8;i++)
  55.         {
  56.             digitalWrite(CLK,LOW);
  57.             if(DATA&0X01)
  58.                digitalWrite(DIO,HIGH);
  59.             else
  60.                digitalWrite(DIO,LOW);
  61.             DATA>>=1;
  62.             digitalWrite(CLK,HIGH);
  63.         }
  64. }
  65. unsigned char TM1638_Read(void)                                        //讀數(shù)據(jù)函數(shù)
  66. {
  67.         unsigned char i;
  68.         unsigned char temp=0;;       
  69.         pinMode(DIO,INPUT);//設(shè)置為輸入
  70.         for(i=0;i<8;i++)
  71.         {
  72.               temp>>=1;
  73.             digitalWrite(CLK,LOW);
  74.               if(digitalRead(DIO)==HIGH)
  75.                 temp|=0x80;
  76.             digitalWrite(CLK,HIGH);
  77.                
  78.         }
  79.         return temp;
  80. }
  81. void Write_COM(unsigned char cmd)                //發(fā)送命令字
  82. {
  83.         digitalWrite(STB,LOW);
  84.         TM1638_Write(cmd);
  85.         digitalWrite(STB,HIGH);
  86. }
  87. unsigned char Read_key(void)
  88. {
  89.         unsigned char c[4],i,key_value=0;
  90.         digitalWrite(STB,LOW);
  91.         TM1638_Write(0x42);                           //讀鍵掃數(shù)據(jù) 命令
  92.         for(i=0;i<4;i++)               
  93.           {
  94.             c[i]=TM1638_Read();
  95.         }
  96.         digitalWrite(STB,HIGH);                                                   //4個(gè)字節(jié)數(shù)據(jù)合成一個(gè)字節(jié)
  97.         for(i=0;i<4;i++)
  98.         {
  99.             key_value|=c[i]<<i;
  100.         }       
  101.         for(i=0;i<8;i++)
  102.         {
  103.             if((0x01<<i)==key_value)
  104.             break;
  105.         }
  106.         return i;
  107. }
  108. void Write_DATA(unsigned char add,unsigned char DATA)                //指定地址寫(xiě)入數(shù)據(jù)
  109. {
  110.         Write_COM(0x44);
  111.         digitalWrite(STB,LOW);
  112.         TM1638_Write(0xc0|add);
  113.         TM1638_Write(DATA);
  114.         digitalWrite(STB,HIGH);
  115. }
  116. void Write_allLED(unsigned char LED_flag)                                        //控制全部LED函數(shù),LED_flag表示各個(gè)LED狀態(tài)
  117. {
  118.         unsigned char i;
  119.         for(i=0;i<8;i++)
  120.         {
  121.             if(LED_flag&(1<<i))
  122.               Write_DATA(2*i+1,1);
  123.             else
  124.               Write_DATA(2*i+1,0);
  125.         }
  126. }

  127. //TM1638初始化函數(shù)
  128. void init_TM1638(void)
  129. {
  130.         unsigned char i;
  131.         Write_COM(0x8b);       //亮度 (0x88-0x8f)8級(jí)亮度可調(diào)
  132.         Write_COM(0x40);       //采用地址自動(dòng)加1
  133.         digitalWrite(STB,LOW);                           //
  134.         TM1638_Write(0xc0);    //設(shè)置起始地址
  135.         for(i=0;i<16;i++)           //傳送16個(gè)字節(jié)的數(shù)據(jù)
  136.           TM1638_Write(0x00);
  137.         digitalWrite(STB,HIGH);
  138. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

2113#
ID:513258 發(fā)表于 2019-9-5 18:30 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2114#
ID:513258 發(fā)表于 2019-9-5 20:18 | 只看該作者
37款傳感器與模塊的提法,在網(wǎng)絡(luò)上廣泛流傳,其實(shí)Arduino能夠兼容的傳感器模塊肯定是不止37種的。鑒于本人手頭積累了一些傳感器和模塊,依照實(shí)踐出真知(一定要?jiǎng)邮肿觯┑睦砟睿詫W(xué)習(xí)和交流為目的,這里準(zhǔn)備逐一動(dòng)手試試做實(shí)驗(yàn),不管成功與否,都會(huì)記錄下來(lái)---小小的進(jìn)步或是搞不定的問(wèn)題,希望能夠拋磚引玉。

【Arduino】108種傳感器模塊系列實(shí)驗(yàn)(資料+代碼+圖形+仿真)
實(shí)驗(yàn)一百零七: 2262/2272四路無(wú)線(xiàn)遙控套件M4非鎖接收板 配四鍵無(wú)線(xiàn)遙控器模組




回復(fù)

使用道具 舉報(bào)

2115#
ID:513258 發(fā)表于 2019-9-5 21:34 | 只看該作者


PT2262/PT2272
是臺(tái)灣普城公司生產(chǎn)的一種CMOS 工藝制造的低功耗低價(jià)位通用編解碼電路,PT2262/PT2272 最多可有12 位(A0-A11)三態(tài)地址端管腳(懸空,接高電平,接低電平),任意組合可提供531441地址碼,PT2262 最多可有6 位(D0-D5)數(shù)據(jù)端管腳,設(shè)定的地址碼和數(shù)據(jù)碼從17 腳串行輸出,可用于無(wú)線(xiàn)遙控發(fā)射電路。編碼芯片PT2262 發(fā)出的編碼信號(hào)由:地址碼、數(shù)據(jù)碼、同步碼組成一個(gè)完整的碼字,解碼芯片PT2272 接收到信號(hào)后,其地址碼經(jīng)過(guò)兩次比較核對(duì)后,VT 腳才輸出高電平,與此同時(shí)相應(yīng)的數(shù)據(jù)腳也輸出高電平,如果發(fā)送端一直按住按鍵,編碼芯片也會(huì)連續(xù)發(fā)射。當(dāng)發(fā)射機(jī)沒(méi)有按鍵按下時(shí),PT2262 不接通電源,其17 腳為低電平,所以315MHz 的高頻發(fā)射電路不工作,當(dāng)有按鍵按下時(shí),PT2262 得電工作,其第17 腳輸出經(jīng)調(diào)制的串行數(shù)據(jù)信號(hào),當(dāng)17 腳為高電平期間315MHz 的高頻發(fā)射電路起振并發(fā)射等幅高頻信號(hào),當(dāng)17 腳為低平期間315MHz 的高頻發(fā)射電路停止振蕩,所以高頻發(fā)射電路完全受控于PT2262 的17 腳輸出的數(shù)字信號(hào),從而對(duì)高頻電路完成幅度鍵控(ASK 調(diào)制)相當(dāng)于調(diào)制度為100%的調(diào)幅。

回復(fù)

使用道具 舉報(bào)

2116#
ID:513258 發(fā)表于 2019-9-5 21:46 | 只看該作者


PT2262
構(gòu)成發(fā)射電路,PT2262-IR的VDD是通過(guò)按鍵接通后向芯片供電,這樣靜態(tài)時(shí),PT2262-IR并不耗電,特別適合是電池供電的場(chǎng)合。如果使用電源電壓較低(如3V),二極管應(yīng)選用低壓差的型號(hào)(如1N60等),工作原理相近。無(wú)線(xiàn)發(fā)射電路是由三極管加上電阻,電容,三極管,聲表面濾波器,天線(xiàn)組成。紅外線(xiàn)發(fā)射電路比較簡(jiǎn)單,由電阻、三極管和紅外線(xiàn)發(fā)射管組成。編碼電路主要由編碼芯片完成,每個(gè)遙控器上面的編碼都是通過(guò)集成電路芯片來(lái)完成的。只要我們按下按鍵,編碼將通過(guò)發(fā)射電路以無(wú)線(xiàn)的形式發(fā)送出去。

回復(fù)

使用道具 舉報(bào)

2117#
ID:513258 發(fā)表于 2019-9-5 21:48 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2118#
ID:513258 發(fā)表于 2019-9-5 21:50 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2119#
ID:513258 發(fā)表于 2019-9-5 21:52 | 只看該作者

回復(fù)

使用道具 舉報(bào)

2120#
ID:513258 發(fā)表于 2019-9-5 21:53 | 只看該作者

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表