workshop:통신
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
workshop:통신 [2012/08/13 14:06] – donghee | workshop:통신 [2018/07/18 14:10] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
IC와 통신 하기 | IC와 통신 하기 | ||
- | | + | * [[/UART]] |
- | 2. [[/I2C]] | + | * [[/ |
+ | * [[/I2C]] | ||
+ | * [[/SPI]] | ||
칩간에 통신을 실험해보자! | 칩간에 통신을 실험해보자! | ||
- | |||
- | ====== WS2801 ====== | ||
- | |||
- | LED 드라이버 | ||
- | |||
- | 회로도 | ||
- | {{http:// | ||
- | |||
- | Time | ||
- | |||
- | {{http:// | ||
- | |||
- | {{{ | ||
- | int SDI = 11; // PIN 11 | ||
- | int CKI = 12; // PIN 12 | ||
- | int ledPin = 13; // LED | ||
- | |||
- | void setup() { | ||
- | pinMode(SDI, | ||
- | pinMode(CKI, | ||
- | pinMode(ledPin, | ||
- | | ||
- | // | ||
- | // | ||
- | } | ||
- | |||
- | void loop() { | ||
- | delay(2000); | ||
- | |||
- | while(1){ | ||
- | post_frame(0xFF0000); | ||
- | |||
- | // CLK pin keeps low more than 500uS will make the WS2801 internal status register reset | ||
- | digitalWrite(CKI, | ||
- | delayMicroseconds(500); | ||
- | | ||
- | digitalWrite(ledPin, | ||
- | delay(250); | ||
- | digitalWrite(ledPin, | ||
- | delay(250); | ||
- | } | ||
- | } | ||
- | |||
- | // this_led_color값의 비트를 ws2801에 CKI에 맞추어 SDI를 밀어 넣는다. | ||
- | void post_frame (long this_led_color) { | ||
- | for(byte color_bit = 23 ; color_bit != 255 ; color_bit--) { | ||
- | // | ||
- | | ||
- | digitalWrite(CKI, | ||
- | | ||
- | long mask = 1L << color_bit; | ||
- | //The 1' | ||
- | | ||
- | if(this_led_color & mask) | ||
- | digitalWrite(SDI, | ||
- | else | ||
- | digitalWrite(SDI, | ||
- | | ||
- | digitalWrite(CKI, | ||
- | } | ||
- | } | ||
- | }}} | ||
- | |||
- | 여러개 보낼경우. 이어서 보낸다. | ||
- | |||
- | {{{ | ||
- | post_frame(0xFF0000); | ||
- | post_frame(0x00FF00); | ||
- | // CLK pin keeps low more than 500uS will make the WS2801 internal status register reset | ||
- | digitalWrite(CKI, | ||
- | delayMicroseconds(500); | ||
- | | ||
- | }}} | ||
workshop/통신.1344866765.txt.gz · Last modified: 2018/07/18 14:09 (external edit)