¸¡º÷
AND¸¡º÷
OR¸¡º÷
¥È¥Ã¥×
|
¥ê¥í¡¼¥É
|
¿·µ¬
|
°ìÍ÷
|
¸¡º÷
|
ºÇ½ª¹¹¿·
|
¥Ø¥ë¥×
takada ¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¤·¤ÆºîÀ®
ºÇ¿·¤Î20·ï
2024-04-02
wu
FrontPage
2023-11-15
shiraya
2023-11-14
¥³¥á¥ó¥È/akita
2023-09-25
akita
2023-05-30
sakamoto
2023-05-28
okamura
2022-11-15
kawamura
2022-11-01
youkaichi
2022-10-02
AutoTicketLinkName
2022-02-17
ibe
2022-02-04
nakagawa
2021-11-09
tanaka
2021-09-08
okawa
2021-08-03
tsuzuki
2021-07-28
takebe
2021-04-01
awazu
2020-12-10
moriya
2020-10-26
inoue
2019-12-18
yoshida
Total:0/Today:0
³«»Ï¹Ô:
#contents
//¤â¤¯¤¸¤Ç¤¹
#pcomment(reply)
//¤³¤á¤ó¤È¤Ç¤¹
*2014/4/26 I2C¥«¥é¡¼¥»¥ó¥µ£Ó£±£±£°£µ£¹¡Ý£°£²£Ä£Ô¤Î»È¤¤Êý [...
-ironeÍÑ¡£I2C¤ÇÆ°¤¯¡£¿§¤ÎÂбþ¤¬ÌÌÅݤ¯¤µ¤«¤Ã¤¿¤Î¤ÇºÜ¤»¤Æ¤ª...
»²¹ÍURL¡§http://blog.kemushicomputer.com/2013/08/i2c.html ~
Á°Äó¤È¤·¤Æ¡¢3¥ª¥¯¥¿¡¼¥Ö¤Ë¹ç¤ï¤»¤ë°Ù36¼ïÎर¤é¤¤¤Î¿§¤¬Íߤ·...
¢ªRGB¤Ç¹Í¤¨¤ë¤È3*3*4¤°¤é¤¤¤¬ÂÅÅö ~
¢ªÄ¾Àܼè¤Ã¤Æ¤¤¿Ãͤò¶ãÌ£¤·¤Æ¤â¾å¼ê¤¯¤¤¤«¤Ê¤¤(ÌÀ¤ë¤µ¤Ë¤è¤Ã...
¢ªÀÖ³°Àþ¿®¹æ¤ò¼è¤Ã¤ÆÍè¤ì¤ë¤È¤¤¤¦ÊØÍø¤Êµ¡Ç½¤Ëµ¤ÉÕ¤¯¡£ÌÀ¤ë¤µ...
¢ª¤¤ì¤¤¤ËÊѲ½¤·¤¿¡£¤È¤¤¤¦¤ï¤±¤ÇrgbÃÍ/IRÃͤÇÊäÀµ¤Ç¤¤ë¡£¤Þ...
¢ª¤³¤ì¤ò3*3*4Åùʬ¤·¤¿¤â¤Î¤òºÇ½ªÅª¤Ê¿§È½ÃǤ˻Ȥ¦ ~
/*******************************************************...
* S11059_02dt I2C color sensor test sketch v20130818 ...
*
* http://www.hamamatsu.com/jp/ja/product/new/S11059-02DT...
* http://www.hamamatsu.com/jp/en/product/new/S11059-02DT...
*
* tested boards
* MSP430 LaunchPad(G2553) (Energia IDE 0101E009 & patch...
* Arduino 1.0 or later (need 3.3V board or I2C level c...
*
* MSP430LaunchPad (& Energia)
* before enabling I2C bus, remove led2 JUMPER PIN
* Energia IDE must be patched with latest cores library ...
* (In energiaIDEdirectory/hardware/MSP430/cores)
********************************************************...
#include "Wire.h"
#define device_address 0x2A
#define control_reg 0x00
/* //¿§¤Î¼ïÎà¡£3¥ª¥¯¥¿¡¼¥Ö¤Ë¹ç¤ï¤»¤Æ36¼ïÎà¤Ë¤Ê¤Ã¤Æ¤¤¤ë
#define black 0
#define dark_blue 1
#define navy 2
#define blueblue 3
#define greenteamilk 4
#define emerald 5
#define sky 6
#define aqua 7
#define yellowgreen 8
#define lightemerald 9
#define shallowsea 10
#define lightaqua 11
#define redblack 12
#define lightredpurple 13
#define lightpurple 14
#define lightbluepurple 15
#define mastard 16
#define ash 17
#define lightblueash 18
#define lightbluewhiteash 19
#define neonyellowgreen 20
#define lightashyellowgreen 21
#define lightashemerald 22
#define lightashwhiteblue 23
#define redred 24
#define pink 25
#define pinkpurple 26
#define purple 27
#define orange 28
#define fleshcolor 29
#define whitepink 30
#define kirby 31
#define yellow 32
#define lightyellow 33
#define verylightyellow 34
#define white 35
*/
//¥»¥ó¥µ¡¼¤«¤é¤ÎÃͤò»ý¤Ã¤Æ¤¯¤ë¡£16bit¤Ê¤Î¤Ç0¡Á65535
uint16_t red = 0;
uint16_t green = 0;
uint16_t blue = 0;
uint16_t IR = 0;
//¥»¥ó¥µ¡¼¤ÎRGBÃͤ«¤é¿§¤ò·èÄꤹ¤ëºÝ¤Ë»È¤¦
uint16_t r = 0;
uint16_t g = 0;
uint16_t b = 0;
//group¡¡¥»¥ó¥µ¡¼¤«¤éÊäÀµ¸å¤ÎÃͤ¬ÂçÂÎ12¤°¤é¤¤¤Þ¤Ç¤Ê¤Î¤Ç¡¢
uint16_t r_1 = 4;
uint16_t r_2 = 8;
uint16_t r_3 = 20;
uint16_t g_1 = 4;
uint16_t g_2 = 8;
uint16_t g_3 = 20;
uint16_t b_1 = 3;
uint16_t b_2 = 6;
uint16_t b_3 = 9;
uint16_t b_4 = 20;
uint16_t color = 0;
uint16_t colorGroup[3][3][4] = {
{
{0,1,2,3},
{4,5,6,7},
{8,9,10,11}
},
{
{12,13,14,15},
{16,17,18,19},
{20,21,22,23}
},
{
{24,25,26,27},
{28,29,30,31},
{32,33,34,35}
}
};
void getRGB();
void getColor();
void getColor()
{
if(red <= r_1){r = 0;}
else if(red <= r_2){r = 1;}
else if(red <= r_3){r = 2;}
if(blue <= b_1){b = 0;}
else if(blue <= b_2){b = 1;}
else if(blue <= b_3){b = 2;}
else if(blue <= b_4){b = 3;}
if(green <= g_1){g = 0;}
else if(green <= g_2){g = 1;}
else if(green <= g_3){g = 2;}
color = colorGroup[r][g][b];
}
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
getRGB();
Serial.print(red);
Serial.print(',');
Serial.print(green);
Serial.print(',');
Serial.print(blue);
Serial.print(',');
Serial.println(IR);
red= red/IR;
green=green/IR;
blue=blue/IR;
getColor();
Serial.print(red);
Serial.print(',');
Serial.print(green);
Serial.print(',');
Serial.print(blue);
Serial.print(',');
Serial.println(color);
delay(500);
}
void getRGB()
{
uint16_t colordata= 0;
//¤³¤ÎÊդΥץí¥È¥³¥ë¤Ï¥Ç¡¼¥¿¥·¡¼¥È¤ËºÜ¤Ã¤Æ¤¤¤ë
Wire.beginTransmission(device_address);
Wire.write(control_reg);
Wire.write(0x83); // ADC reset, wakeup, low gain, fixed...
Wire.endTransmission(false);
Wire.beginTransmission(device_address);
Wire.write(control_reg);
//ADC start, wakeup, low gain, fixed time mode, 179.2ms
Wire.write(0x03);
Wire.endTransmission(true);
//probably for RGB+IR
delay(180*4); //total exposure time
Wire.beginTransmission(device_address);
Wire.write(0x03);
Wire.endTransmission(false);
Wire.requestFrom(0x2A,8,true);
//read data
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
red = colordata;
colordata =0;
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
green = colordata;
colordata =0;
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
blue = colordata;
colordata =0;
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
IR = colordata;
return;
}
¾å¼ê¤¯Æ°¤¤¤¿¤¬²þÁ±¤ÏÅÔÅÙ¤·¤Æ¤¤¤¤¿¤¤¡£
*2014/4/26 OZV¤Î»È¤¤Êý [#q72fd410]
-ironeÍÑ¡£XBee¤È¤¢¤Þ¤êÊѤï¤é¤Ê¤¤¤¬¡¢¥Ñ¥±¥Ã¥È¤òºîÀ®¤·¤¿¤ê...
-¥×¥í¥°¥é¥à ~
-send¦ ~
#include <SoftwareSerial.h>
SoftwareSerial ozvSerial(10, 11); // RX, TX
//send packet, for the last 3elements, length, data and ...
byte send[10]={0xFE, 0x05, 0x2A, 0x02, 0x00, 0x00, 0x00,...
//length of data
int length = 0x01;
//data
int data = 0xCA;
int i = 0; //loop
void setup(){
Serial.begin(9600);
ozvSerial.begin(38400);
//complete send packet
send[sizeof(send) - 3] = length;
send[sizeof(send) - 2] = data;
//culculate checksum and complete send command
for(i = 1; i < sizeof(send) - 1; i++){
send[sizeof(send) - 1] = send[i] ^ send[sizeof(se...
}
}
void loop(){
//send
delay(1000);
ozvSerial.write(send,sizeof(send));
}
-receive¦ ~
#include <SoftwareSerial.h>
SoftwareSerial ozvSerial(10, 11); // RX, TX
// for the last 2elements, data and SUM
//receive packet
byte receive[12];
//data from received packet
int getData = 0x00;
//serial received data
byte receivebyte = 0x00;
int i = 0;//loop
int count = 0;//insert data into receive array
int start = 0;//start inserting
int receiveLen = 12;//receive packet length is 12
void setup(){
Serial.begin(9600);
ozvSerial.begin(38400);
}
void loop(){
//receive
if(ozvSerial.available()){
receivebyte = ozvSerial.read();
//0xFE is start of a paket
if(receivebyte == 0xFE){
start = 1;
//other than 0xFE, 11elements remaining to receive
}else if(start == 1 && count < receiveLen - 1){
receive[count] = receivebyte;
count++;
//when finished inserting, get data from the packet
}else if(count == receiveLen - 1){
count = 0;
start = 0;
getData = receive[receiveLen - 3];
Serial.print("data = ");
Serial.println(getData, HEX);
}
}
}
¾Ü¤·¤¯¤Ï˺¤ì¤¿¤Î¤Ç¥×¥í¥°¥é¥à¤À¤±¤Ç¤â˺È÷Ï¿¤È
*2014/1/10 Äɵ [#q314a404]
-ÆüËܸì¤Îencoding¤Ï¡¢%!TEX encoding = UTF-8 Unicode¤Î°ìʸ...
*2014/1/10 TeX¤òMac¤Ë¥¤¥ó¥¹¥È¡¼¥ë¡¦¥³¥Þ¥ó¥É¤Î¥Ñ¥¹¤òÄ̤¹ [...
-º£¹¹¤Ê¤¬¤é¥Þ¥Ã¥¯¤ËTeX´Ä¶¤ò¹½ÃÛ¤·¤¿¡£LaTeX¤â»È¤¨¤Æpdf¥Õ...
-sasada¤µ¤ó¤Îºî¶ÈÆü»ï¤ò¥Ò¥ó¥È¤Ë¿Ê¤á¤¿¢ªhttp://ifdl.ec.t.ka...
-¡¥¤¥ó¥¹¥È¡¼¥ë¡¦½é´üÀßÄê ~
http://d.hatena.ne.jp/lucky_pool/20120209/1328758735 ¤³¤Î...
1. Drag & Drop UpTeX ~
2. ESP Ghostscript¤Ë²Ã¤¨¤Æ¡¢~
3. UpTeXº¹Ê¬¥Õ¥¡¥¤¥ë ~
¤â¡¢¤ÈÊ̤ΤȤ³¤í¤Ç½ñ¤¤¤Æ¤¢¤Ã¤¿¤Î¤Ç¥À¥¦¥ó¥í¡¼¥É¡£3¤Ë¤Ä¤¤¤Æ...
/Applications/UpTeX.app/teTeX/bin¤Ë¥É¥é¥Ã¥°&¥É¥í¥Ã¥×¤·¤Æ...
¥µ¥¤¥È¤Ë½ñ¤¤¤Æ¤¢¤ë½é´üÀßÄê¤Ï¤·¤Æ¤ª¤¯¡£ ~
¤µ¤é¤Ë¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥óÆâ¤ÎTeXPad¤Ï¡¢°ìÅÙ¥À¥Ö¥ë¥¯¥ê¥Ã¥¯...
-¢¥Ñ¥¹¤òÄ̤¹ ~
¥³¥Þ¥ó¥É¤«¤éľÀÜ¥³¥ó¥Ñ¥¤¥ë¤ädiv¥Õ¥¡¥¤¥ë¤òºî¤ëºÝ¤Ë¤Ï¡¢¥³¥Þ...
http://xn--p8ja5bwe1i.jp/wiki/%E3%81%9D%E3%81%AE%E4%BB%96...
¤³¤Îµ»ö¤¬¤È¤Æ¤â»²¹Í¤Ë¤Ê¤ë¡£¤¿¤À¤·¡¢.bashrc¤ÎºîÀ®¤Î»ÅÊý¤È...
https://gist.github.com/disktnk/4104284 ¾åµ2¤Ä¤Î²ò·èË¡¤¬...
¤µ¤é¤Ë¡¢ÊÔ½¸¤Î»ÅÊý¤ÈÊݸ¡¦½ªÎ»¤Î»ÅÊý¤Ï ~
http://www14.plala.or.jp/campus-note/vine_linux/operation...
Íפ¹¤ë¤Ë¡¢.bashrc¤ò³«¤¤¤Æi¤ò²¡¤¹¤ÈÊÔ½¸²èÌ̤ˤʤꡢ¥³¥Þ¥ó...
¤³¤³¤Þ¤Ç¤¬½ª¤ï¤ë¤È¥Ñ¥¹¤Î³Îǧ¤ò¤¹¤ë¡£¥¿¡¼¥ß¥Ê¥ë¤Ë¡¡platex ...
¤¢¤È¤Ï¥Á¥å¡¼¥È¥ê¥¢¥ëhttp://www.comp.tmu.ac.jp/tsakai/lect...
platex sample.tex
¤Ç¥¨¥é¡¼¤¬¤Ê¤±¤ì¤Ðdvi¥Õ¥¡¥¤¥ë¤¬¤Ç¤¤Æ¡¢ ~
dvipdfmx sample.dvi ~
¤Çpdf¥Õ¥¡¥¤¥ë¤¬¤Ç¤¤ë¡£ ~
*2013/12/8 RFM12B(Èù¼å̵Àþ¥â¥¸¥å¡¼¥ë)¤ò»È¤Ã¤Æ¤ß¤¿ [#y7e8e...
-ÀèÀ¸¤Ë夤¤¿¥é¥¤¥Ö¥é¥ê¤ò¤¤¤¸¤Ã¤Æ¤ß¤¿
-̤´°À®Éôʬ(Åž춯Å٤η׻»¡¦ironeÍѤ˴°Á´arduino UNOÈ´¤...
-´°À®Éôʬ(¥Ç¡¼¥¿¤ÎÁ÷¿®¡¦¼õ¿®)
-SPIÄÌ¿®¤Ë¤è¤Ã¤ÆÀ©¸æ¤¹¤ë¡£
¡½àÈ÷¡§
¥Ç¡¼¥¿¥·¡¼¥È
http://www.hoperf.com/upload/rf/rfm12b.pdf
¥³¥Þ¥ó¥É
http://www.hoperf.com/upload/rf/rfm12b.pdf
¥³¥Þ¥ó¥ÉÁḫɽ¡¡
http://tools.jeelabs.org/rfm12b.html
http://www.sevenwatt.com/main/
ÅÅÇȶ¯ÅÙ¡¡
http://eleclog.quitsq.com/2011/11/rfm12b-radio-act.html
Arduino cookbook
https://www.inkling.com/read/arduino-cookbook-michael-mar...
¥Ñ¥±¥Ã¥ÈÆâÍÆ¡¡
http://lowpowerlab.com/blog/2012/12/28/rfm12b-arduino-lib...
http://lowpowerlab.com/blog/2013/06/20/rfm69-library/
http://jeelabs.org/2011/12/11/inside-the-rf12-driver-part...
2¿Ê¿ô·×»»¡¡
http://hogehoge.tk/tool/number.html
Arduino¥Ô¥óÇÛÃÖ¡¡
http://wiki.onakasuita.org/pukiwiki/?Arduino%2F%E3%83%94%...
¢²óÏ©¡§
#ref(rfm_1.png)
º£²ó¤Ï¤³¤ì¤é¤Ë²Ã¤¨¤ÆnINT/VDI, FSK/DATA/nFFS, DCLK/CFIL/FF...
Arduino UNO¤Ï5V¤ÇÆ°ºî¤¹¤ë¤Î¤Ç¡¢RFM12B¤ËÆþ¤ë¿®¹æ¤òʬ°µ¤¹¤ë...
£¥é¥¤¥Ö¥é¥ê¡§
-RF12.cpp
/*useful command: http://tools.jeelabs.org/rfm12b.html
arduino¤ò»ÈÍѤ¹¤ë¤È¤¤Ï16MHz¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç/4(¥Ç¥Õ¥©¥ë...
#define arduino
ÀèÀ¸¤Î¥é¥¤¥Ö¥é¥ê¤«¤éÊѹ¹¤·¤¿²Õ½ê */
#define changed
/*commands*/
#define SET_TX 0x8279
#define SET_RX 0x82D9
#define RESET 0x0000
#define STATUS_CHECK 0x0000
#define TX_SEND 0xB800 //+ data
#define RX_RECEIVE 0xB000
#define CONFIGURATION 0x80D7 // el(enable tx regigter),...
#define SET_FREQUENCY 0xA4B0 // 433MHz
#define SET_DATARATE 0xC623 // 9.6kbps
#define SET_PLL 0xCC17 // CLK=2.5MHz, !ddy ddit, PLL BW...
#define RX_CONTROL 0x94C2 // VDI,FAST,67kHz,LNA=0dBm,RS...
#define Data_Filter_Clock_Recovery 0xC2AC // AL,!ml,DIG...
#define FIFO_RESET_MODE 0xCA83 // FIFO8,2byte-SYNC,!AL,...
#define TX_CONTROL 0x9850 // !mp,90kHz,MAX OUT TXpower=...
#define AUTO_FREQUENCY_CONTROL 0xC483 // @PWR,NO RSTRIC...
#define SET_WAKEUP_TIMER 0xE000 // wake up timer / NOT ...
#define SET_LOW_DUTY_CYCLE 0xC800 // low duty cycle / N...
#define SET_LOW_BATTERY_DETECT_uC_CLK 0xC049 // 1.66MHz...
#define SET_SYNC_PATTERN 0xCED4 // SYNC=2DD4
//status
#define TX_READY 0x8000
#define FIFO_REACHED 0x8000
//pin
#define SPI_MOSI 11
#define SPI_MISO 12
#define SPI_SCK 13
#include <pins_arduino.h>
#include <avr/interrupt.h>
#include <Arduino.h>
#include <RF12.h>
int nIRQ_pin, SS_pin, RST_pin;
int mode;
uint8_t RF12::spi_byte(uint8_t out) {
SPDR = out;
while (!(SPSR & _BV(SPIF)));
return SPDR;
}
uint16_t RF12::xfer_byte(uint16_t cmd)
{
uint16_t dat = 0;
digitalWrite(SS_pin, 0);
dat = spi_byte(cmd >> 8) << 8;
dat |= spi_byte(cmd);
digitalWrite(SS_pin, 1);
return(dat);
}
void RF12::send_byte(byte data)
{
uint16_t d;
// while(!((d = xfer_byte(0x0000)) & 0x8000)) Serial.p...
//send 0000(status check). when returned 8000 TX is ready
while(!(xfer_byte(STATUS_CHECK) & TX_READY)); // wait f...
xfer_byte(TX_SEND + data);
delay(1);
}
//sending 1bit per time
//would I need this?
void RF12::send_data(byte *data, byte len)
{
byte cksum = 0;
for (int i = 0; i < len; i++){
send_byte(data[i]);
cksum += data[i];
}
send_byte(cksum);
}
//wait(blocks) until it receives -> it's okay cuz used ...
#ifdef changed
byte RF12::receive_byte()
{
//interrupt request output(from RFM12B), active low
while(digitalRead(nIRQ_pin) == 1); // wait for any data ...
//status check, reset functions
//xfer_byte(0x0000);
// while(!(xfer_byte(0x0000) & 0x8000))Serial.println(x...
//read 8 bits from the receiver FIFO (even if FIFO not ...
xfer_byte(RESET);
return(xfer_byte(RX_RECEIVE));
}
#else
byte RF12::receive_byte()
{
//interrupt request output(from RFM12B), active low
while(digitalRead(nIRQ_pin) == 1); // wait for any data...
//status check, reset functions
xfer_byte(0x0000);
//read 8 bits from the receiver FIFO (even if FIFO not ...
return(xfer_byte(0xB000));
}
#endif
//needed to recaive less than a byte?
byte *RF12::receive_data(byte *data, byte len)
{
int i;
for (i = 0; i < len; i++){
data[i] = receive_byte();
}
return(data);
}
void RF12::begin(uint8_t nIRQ, uint8_t SS, uint8_t RST)
{
nIRQ_pin = nIRQ;
SS_pin = SS;
RST_pin = RST;
pinMode(RST_pin, INPUT);
// digitalWrite(RST_pin, 0);
digitalWrite(SS_pin, 1);
pinMode(SS_pin, OUTPUT);
//digital 11,12,13 is fixed
//faster when set it directly?
#ifdef changed
DDRB |= ((1<<DDB3)|(1<<DDB4)|(1<<DDB5));
#else
pinMode(SPI_MOSI, OUTPUT);
pinMode(SPI_MISO, INPUT);
pinMode(SPI_SCK, OUTPUT);
#endif
//need to make this smaller than 2.5MHz? arduino is 16MHz
SPCR = _BV(SPE) | _BV(MSTR); // SPI master enable, Mode0
#ifdef arduino
SPSR |= _BV(SPI2X);
#endif
pinMode(nIRQ_pin, INPUT);
digitalWrite(nIRQ_pin, 1); // pull-up, active low
//status check for return and initialization
xfer_byte(RESET); // intitial SPI transfer added to avo...
// wait until RFM12B is out of power-up reset, this tak...
//empty Tx buffer
xfer_byte(TX_SEND); // in case we're still in OOK mode
//reset again and again
while (digitalRead(nIRQ_pin) == 0) xfer_byte(RESET);
//yes, commands start
//enable internal register and FIFO mode ---> why? need...
xfer_byte(CONFIGURATION); // el, ef 12.0pF, 433MHz
//fastest way it might be: turning on the whole receive...
//I don't understand here according to datasheet
#ifdef changed
xfer_byte(0x82d9); // RX mode -> in case didn't set the...
xfer_byte(SET_FREQUENCY); // 433MHz
xfer_byte(SET_DATARATE); // 9.6kbps
xfer_byte(SET_PLL); // CLK=2.5MHz, !ddy ddit, PLL BW=256k
//especially here
//xfer_byte(TX_CONTROL); // !mp,90kHz,MAX OUT TXpower=0...
xfer_byte(RX_CONTROL); // VDI,FAST,67kHz,LNA=0dBm,RSSI=...
#else
//receiver baseband circuite separately switched on
xfer_byte(0x82d9); // RX mode -> in case didn't set the...
xfer_byte(0xA640); // 437MHz (430+0.0025*(0x640)[MHz])
xfer_byte(0xC647); // 4.8kbps
xfer_byte(0xCC77); // CLK=2.5MHz, !ddy ddit, PLL BW=256k
xfer_byte(0x94A2); // VDI,FAST,134kHz,LNA=0dBm,RSSI=-91...
#endif
//Data Filter & Clock Recovery
xfer_byte(Data_Filter_Clock_Recovery); // AL,!ml,DIG,DQ...
//FIFO and reset mode
xfer_byte(FIFO_RESET_MODE); // FIFO8,2byte-SYNC,!AL,ff,...
//Automatic Frequency Control
xfer_byte(AUTO_FREQUENCY_CONTROL); // @PWR,NO RSTRIC,!s...
//replaced---------------------------------------------...
//TX control
xfer_byte(TX_CONTROL); // !mp,90kHz,MAX OUT TXpower=0(m...
//-----------------------------------------------------...
xfer_byte(SET_WAKEUP_TIMER); // wake up timer / NOT USE
xfer_byte(SET_LOW_DUTY_CYCLE); // low duty cycle / NOT ...
//Low Battery Detect and µC Clock
xfer_byte(SET_LOW_BATTERY_DETECT_uC_CLK); // 1.66MHz,3....
//Synchronization Pattern
xfer_byte(SET_SYNC_PATTERN); // SYNC=2DD4
delay(1);
}
void RF12::set_tx_power(uint8_t pow)
{
//just setting the power on TX Configuration Command
xfer_byte(TX_CONTROL + (pow & 0x07));
}
uint16_t RF12::read_status(void)
{
return(xfer_byte(STATUS_CHECK));
}
RF12::RF12(void)
{
}
void RF12::set_mode(uint8_t md)
{
mode = md;
// xfer_byte(0x8239); // !er, !ebb, et, es, ex, !eb, ...
// xfer_byte(0x82D9); // er, ebb, !et, es, ex, !eb, ...
//new--------------------------------------------------...
//xfer_byte(0x8279); // !er, ebb, et, es, ex, !eb, !ew,...
// xfer_byte(0x82D9); // er, ebb, !et, es, ex, !eb, !...
#ifdef changed
if (md == RF12_MODE_TX) xfer_byte(SET_TX);
else if (md == RF12_MODE_RX) xfer_byte(SET_RX);
#else
if (md == RF12_MODE_TX) xfer_byte(0x8239);
else if (md == RF12_MODE_RX) xfer_byte(0x82d9);
#endif
}
int RF12::available(void)
{
if (digitalRead(nIRQ_pin) == 0) return(1);
else return(0);
}
-Á÷¼õ¿®¤Îino¥Õ¥¡¥¤¥ë
Rx:
#include <RF12.h>
int RF12_SS = 10;
int RF12_nIRQ = 9;
int RF12_RST = 8;
uint8_t payload[16];
uint16_t pckt;
RF12 rf12 = RF12();
byte data;
byte packet[16];
void setup()
{
Serial.begin(9600);
rf12.begin(RF12_nIRQ, RF12_SS, RF12_RST);
rf12.set_mode(RF12_MODE_RX);
Serial.println("Ready Rx");
}
int header = 4;
int tail = 6;
int index = 0, check = 0;
void loop()
{
//uint8_t c;
if (rf12.available()){
data = rf12.receive_byte();
if((data == 0xAA) || (data == 0x55)) ; else Serial.writ...
}
//Serial.println();
}
Tx:
#include <RF12.h>
int RF12_SS = 10;
int RF12_nIRQ = 9;
int RF12_RST = 8;
uint16_t payload[16];
uint16_t c;
RF12 rf12 = RF12();
void setup()
{
Serial.begin(9600);
pinMode(4, OUTPUT);
rf12.begin(RF12_nIRQ, RF12_SS, RF12_RST);
rf12.set_mode(RF12_MODE_TX);
Serial.println("TX ready");
c = '!';
}
void loop()
{
//packet format - only activating necessary parts for ju...
//see http://jeelabs.org/2011/12/11/inside-the-rf12-driv...
//or http://lowpowerlab.com/blog/2012/12/28/rfm12b-ardui...
//for full packet information
//necessary part(5 bytes)
//preamble
rf12.send_byte(0xAA);
rf12.send_byte(0xAA);
rf12.send_byte(0xAA);
//SYN-ox2d
rf12.send_byte(0x2D);
//SYN-network ID (network group (can be in the range 1-2...
rf12.send_byte(0xD4);
//header
//CTLflag + DestID(unique node ID of receiver (1 through...
//0 + 55
//rf12.send_byte(c);
rf12.send_byte(0x55);
//ACK + SourceID(unique node ID of receiver (1 through 3...
//1 + 42?
rf12.send_byte(0xaa);
//DataLength
rf12.send_byte(0x55);
//Data
rf12.send_byte(0xaa);
rf12.send_byte(c); //CRC
rf12.send_byte(c+1);
rf12.send_byte(c+2);
rf12.send_byte(0x55);
//CRC
rf12.send_byte(0xaa);
rf12.send_byte(0x55);
rf12.send_byte(0xaa);
rf12.send_byte(0xaa);
rf12.send_byte(0xaa);
//Serial.println("Sent.");
digitalWrite(4, HIGH);
delay(250);
digitalWrite(4, LOW);
delay(250);
//}
}
Ãí°Õ¡§Serial.print¤ò»È¤¦¤ÈSerial¤¬¥Ï¥¤¤Ë¤Ê¤Ã¤Æ¤¤¤ë»þ¤Ë²¿...
100²ó¤Ë1²ó¤°¤é¤¤Ãͤò´Ö°ã¤¨¤ë¤³¤È¤¬¤¢¤ë¡£
¾åµ¥×¥í¥°¥é¥à¤ÎºÙ¤«¤¤ÆâÍƤˤĤ¤¤Æ¤Ï¸å¤Û¤É¹¹¿·Í½Äê
*2013/12/8 Serial.print¤ÈSerial.write [#hdc93cf4]
-»²¹Í: http://arduino.cc/en/Serial/write
1byte¤¢¤ë¤¤¤Ï¤½¤ì°Ê¾å¤Î¥Ð¥¤¥Èñ°ÌËè¤Ë¡¢Serial.write¤Ï¥Ð¥¤...
*2013/9/30 unsigned¤Ëµ¤¤ò¤Ä¤±¤ë [#m66236ad]
-¤¿¤À¤Îint¤Ç-¤¬¤Ä¤¯¤Î¤ÏÃͤ¬Â礤¤¾ì¹ç
*2013/9/26 ATmega3238P¥Ö¡¼¥È¥í¡¼¥À¸å¤Î¥¹¥±¥Ã¥Á½ñ¤¹þ¤ß¥á...
-¥ê¥»¥Ã¥È¥¹¥¤¥Ã¥Á¤Ë¤Ä¤±¤ë¥³¥ó¥Ç¥ó¥µ¤Ï0.1¦ÌF¤À¤È¾å¼ê¤¯¤¤¤¯...
* 2013/9/24 ATmega328P¤Î¥Ö¡¼¥È¥í¡¼¥À¡¼½ñ¤¹þ¤ß¥á¥â(PU) [#...
-¥Ò¥å¡¼¥ºÀßÄêɽ
#ref(3_1.png)
-¤É¤Î¥Ö¡¼¥È¥í¡¼¥À¡¼¤ò»È¤¦¤«¤Ïbootloader.txt¤ËºÜ¤Ã¤Æ¤¤¤ë
-ATmega328p¤Ç¤Ïhttp://ifdl.ec.t.kanazawa-u.ac.jp/~akita/l...
#ref(3_2.png)
-¼ê½ç(µð¾¢¤µ¤ó¤Îºî¶ÈÆü»ï¤â»²¹Í¤Ë¤µ¤»¤Æĺ¤¤Þ¤·¤¿¡£)
-¿Þ¤¬¤¿¤¯¤µ¤ó¤Çʬ¤«¤ê¤ä¤¹¤¤¡¢¡¢¡¢
-http://mizupc8.bio.mie-u.ac.jp/pukiwiki/index.php?Arduin...
* 2013/9/23 ˺È÷Ï¿-Sparkfun.com MP3 Player Shield¤ò»È¤¦»þ...
-Sparkfun.com MP3 Player Shield¤òUNO¤Ç»È¤¦»þ¤Ë¥¤¥ó¥¹¥È¡¼...
-https://www.sparkfun.com/tutorials/295 ¤Î
#ref(2_1.png)
¡¡¤¬Â¸ºß¤·¤Ê¤¤¤Î¤Ç¤¹¤¬¡¢Arduino/libraries/SdFat/SdFatConf...
#ref(2_2.png)
¡¡¤Ë¤¢¤ê¤Þ¤·¤¿¡£¤³¤³¤ÎCS¤ò10¢ª9¤ËÊѤ¨¤ë¤ÈÆ°¤¤Þ¤·¤¿¡£
* Eclipse¤ò»È¤Ã¤ÆJava¤Ç¥·¥ê¥¢¥ëÄÌ¿® [#ga87d6a8]
- Æ°ºî´Ä¶¡§Windows7 64bit
- ¼ê½ç
¡¥·¥ê¥¢¥ëÄÌ¿®¤ò¹Ô¤¤¤¿¤¤Eclipse¤Îpackage²¼¤ËÄɲå饤¥Ö¥é...
#ref(1.png)
¢ÄɲÃÍѤΥ饤¥Ö¥é¥ê¤ò¥¤¥ó¥¹¥È¡¼¥ë
-- http://mfizz.com/oss/rxtx-for-java
¡¡¡¡¤³¤Î¥Õ¥©¥ë¥À¤ò²òÅष¤¿Ãæ¤Î¡¢
¡¡¡¡¡¡rxtxParallel.dll
¡¡¡¡¡¡rxtxSerial.dll
¡¡¡¡¡¡RXTXcomm.jar
¡¡¡¡¤ò¥³¥Ô¡¼¤·¤Æ¡¢¡¤Î¥Õ¥©¥ë¥ÀÆâ¤Ë¥Ú¡¼¥¹¥È
-¤â¤·¤â¥Ñ¥½¥³¥ó¼«ÂΤ˥¤¥ó¥¹¥È¡¼¥ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢Program Fi...
£Eclipse¤ÇLibrary Path¤òÄɲ乤ë
-Eclipse¤òµ¯Æ°
-¤Þ¤º¡¢¿·¤·¤¯ºî¤Ã¤¿¥Õ¥©¥ë¥À¤¬Æþ¤Ã¤Æ¤¤¤ëPackage̾¤ò±¦¥¯¥ê...
¡¡¡¡
¤³¤ì¤Ç¡¢¿·¥Õ¥©¥ë¥À¤¬Package¤ËÃç´ÖÆþ¤ê¡£
¡¡
-Project¥¿¥Ö¤ÎProperties¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¡£Properties¤Îº¸¤ËJ...
-Libraries¥¿¥Ö¤ò¥¯¥ê¥Ã¥¯¡£Add Jars...¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¡¢¡¤Ç...
#ref(2.png)
-¤³¤ì¤ÇÀßÄê¤Ï´°Î»¡£¤¢¤È¤Ï¥×¥í¥°¥é¥à¤ò½ñ¤¯¤Î¤ß¡£
¤¥×¥í¥°¥é¥àºîÀ®
-CommLight.java¡Ê¥á¥¤¥ó¤¬¤¢¤ë¥Õ¥¡¥¤¥ë¡Ë
//port check
//JDK check
import java.io.*;
public class CommLight{
static File sharedText;
public static void main(String[] args){
SerialComm serialcomm = new SerialComm();
serialcomm.open();
int i = 10;
while(i>0){
serialcomm.write((byte)0x34);
try{
Thread.sleep(500);
}catch(Exception e){
}
serialcomm.write((byte)0x20);
try{
Thread.sleep(500);
}catch(Exception e){
}
serialcomm.write((byte)0x78);
try{
Thread.sleep(500);
}catch(Exception e){
}
i--;
}
System.out.println("Hello, World");
}
}
-SerialComm.java
import gnu.io.*;
import java.io.*;
import java.util.*;
public class SerialComm implements SerialPortEventListe...
private SerialPort port;
// private static BufferedReader reader;
private InputStream in;
private OutputStream out;
SerialComm(){
super();
}
public void open(){
try {
// Serial port initialize
CommPortIdentifier portId = CommPortIdentifier.getPort...
port = (SerialPort)portId.open("USB Serial Port", 2000);
port.setSerialPortParams(
9600, // í êM롯ìx[bps]
SerialPort.DATABITS_8, // ÉfÅ[É^...
SerialPort.STOPBITS_1, // ÉXÉgÉb...
SerialPort.PARITY_NONE // ÉpÉäÉ...
);
port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
try{
port.addEventListener(this);
port.notifyOnDataAvailable(true);
in = port.getInputStream();
out = port.getOutputStream();
}catch(TooManyListenersException ex){
System.out.println("Error1: "+ex);
}
} catch (Exception e) {
System.out.println("Error2: " + e);
System.exit(1);
}
}
public void close(){
try{
in.close();
out.close();
port.close();
}catch(Exception e){
System.out.println("close: "+e);
}
}
public void read(){
try{
byte[] buffer;
int temp = in.available();
if(temp>0){
System.out.println("temp: "+temp);
buffer = new byte[temp];
temp = in.read(buffer);
int num = 0;
while(num<temp){
System.out.println("b "+num+": "+Integer.toHexString...
num++;
}
}
in.close();
}catch(Exception e){
System.out.println("error4: "+e);
}
}
public static String toHex(byte[] digest) {
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%1$02X", b));
}
return sb.toString();
}
public void write(byte data){
try{
out.write((byte)data);
out.flush();
//ÉXÉgÉäÅ[ÉÄÇ&...
}catch(Exception e){
System.out.println("port exception: "+e);
}
}
public void run() {
try {
InputStreamReader isr = new InputStreamReader(System.i...
BufferedReader br = new BufferedReader(isr);
OutputStream out = port.getOutputStream();
boolean flagQuit = false;
while (!flagQuit) {
String input = br.readLine();
if (input.length() > 0) {
if (input.equals(":quit"))
break;
input += "\r";
out.write(input.getBytes("US-ASCII"));
}
}
port.close();
} catch (Exception e) {
System.out.println("Error3: " + e);
}
}
public void serialEvent(SerialPortEvent event) {
if (event.getEventType() == SerialPortEvent.DATA_AVAILA...
read();
}
}
}
¥´°À®
½ªÎ»¹Ô:
#contents
//¤â¤¯¤¸¤Ç¤¹
#pcomment(reply)
//¤³¤á¤ó¤È¤Ç¤¹
*2014/4/26 I2C¥«¥é¡¼¥»¥ó¥µ£Ó£±£±£°£µ£¹¡Ý£°£²£Ä£Ô¤Î»È¤¤Êý [...
-ironeÍÑ¡£I2C¤ÇÆ°¤¯¡£¿§¤ÎÂбþ¤¬ÌÌÅݤ¯¤µ¤«¤Ã¤¿¤Î¤ÇºÜ¤»¤Æ¤ª...
»²¹ÍURL¡§http://blog.kemushicomputer.com/2013/08/i2c.html ~
Á°Äó¤È¤·¤Æ¡¢3¥ª¥¯¥¿¡¼¥Ö¤Ë¹ç¤ï¤»¤ë°Ù36¼ïÎर¤é¤¤¤Î¿§¤¬Íߤ·...
¢ªRGB¤Ç¹Í¤¨¤ë¤È3*3*4¤°¤é¤¤¤¬ÂÅÅö ~
¢ªÄ¾Àܼè¤Ã¤Æ¤¤¿Ãͤò¶ãÌ£¤·¤Æ¤â¾å¼ê¤¯¤¤¤«¤Ê¤¤(ÌÀ¤ë¤µ¤Ë¤è¤Ã...
¢ªÀÖ³°Àþ¿®¹æ¤ò¼è¤Ã¤ÆÍè¤ì¤ë¤È¤¤¤¦ÊØÍø¤Êµ¡Ç½¤Ëµ¤ÉÕ¤¯¡£ÌÀ¤ë¤µ...
¢ª¤¤ì¤¤¤ËÊѲ½¤·¤¿¡£¤È¤¤¤¦¤ï¤±¤ÇrgbÃÍ/IRÃͤÇÊäÀµ¤Ç¤¤ë¡£¤Þ...
¢ª¤³¤ì¤ò3*3*4Åùʬ¤·¤¿¤â¤Î¤òºÇ½ªÅª¤Ê¿§È½ÃǤ˻Ȥ¦ ~
/*******************************************************...
* S11059_02dt I2C color sensor test sketch v20130818 ...
*
* http://www.hamamatsu.com/jp/ja/product/new/S11059-02DT...
* http://www.hamamatsu.com/jp/en/product/new/S11059-02DT...
*
* tested boards
* MSP430 LaunchPad(G2553) (Energia IDE 0101E009 & patch...
* Arduino 1.0 or later (need 3.3V board or I2C level c...
*
* MSP430LaunchPad (& Energia)
* before enabling I2C bus, remove led2 JUMPER PIN
* Energia IDE must be patched with latest cores library ...
* (In energiaIDEdirectory/hardware/MSP430/cores)
********************************************************...
#include "Wire.h"
#define device_address 0x2A
#define control_reg 0x00
/* //¿§¤Î¼ïÎà¡£3¥ª¥¯¥¿¡¼¥Ö¤Ë¹ç¤ï¤»¤Æ36¼ïÎà¤Ë¤Ê¤Ã¤Æ¤¤¤ë
#define black 0
#define dark_blue 1
#define navy 2
#define blueblue 3
#define greenteamilk 4
#define emerald 5
#define sky 6
#define aqua 7
#define yellowgreen 8
#define lightemerald 9
#define shallowsea 10
#define lightaqua 11
#define redblack 12
#define lightredpurple 13
#define lightpurple 14
#define lightbluepurple 15
#define mastard 16
#define ash 17
#define lightblueash 18
#define lightbluewhiteash 19
#define neonyellowgreen 20
#define lightashyellowgreen 21
#define lightashemerald 22
#define lightashwhiteblue 23
#define redred 24
#define pink 25
#define pinkpurple 26
#define purple 27
#define orange 28
#define fleshcolor 29
#define whitepink 30
#define kirby 31
#define yellow 32
#define lightyellow 33
#define verylightyellow 34
#define white 35
*/
//¥»¥ó¥µ¡¼¤«¤é¤ÎÃͤò»ý¤Ã¤Æ¤¯¤ë¡£16bit¤Ê¤Î¤Ç0¡Á65535
uint16_t red = 0;
uint16_t green = 0;
uint16_t blue = 0;
uint16_t IR = 0;
//¥»¥ó¥µ¡¼¤ÎRGBÃͤ«¤é¿§¤ò·èÄꤹ¤ëºÝ¤Ë»È¤¦
uint16_t r = 0;
uint16_t g = 0;
uint16_t b = 0;
//group¡¡¥»¥ó¥µ¡¼¤«¤éÊäÀµ¸å¤ÎÃͤ¬ÂçÂÎ12¤°¤é¤¤¤Þ¤Ç¤Ê¤Î¤Ç¡¢
uint16_t r_1 = 4;
uint16_t r_2 = 8;
uint16_t r_3 = 20;
uint16_t g_1 = 4;
uint16_t g_2 = 8;
uint16_t g_3 = 20;
uint16_t b_1 = 3;
uint16_t b_2 = 6;
uint16_t b_3 = 9;
uint16_t b_4 = 20;
uint16_t color = 0;
uint16_t colorGroup[3][3][4] = {
{
{0,1,2,3},
{4,5,6,7},
{8,9,10,11}
},
{
{12,13,14,15},
{16,17,18,19},
{20,21,22,23}
},
{
{24,25,26,27},
{28,29,30,31},
{32,33,34,35}
}
};
void getRGB();
void getColor();
void getColor()
{
if(red <= r_1){r = 0;}
else if(red <= r_2){r = 1;}
else if(red <= r_3){r = 2;}
if(blue <= b_1){b = 0;}
else if(blue <= b_2){b = 1;}
else if(blue <= b_3){b = 2;}
else if(blue <= b_4){b = 3;}
if(green <= g_1){g = 0;}
else if(green <= g_2){g = 1;}
else if(green <= g_3){g = 2;}
color = colorGroup[r][g][b];
}
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
getRGB();
Serial.print(red);
Serial.print(',');
Serial.print(green);
Serial.print(',');
Serial.print(blue);
Serial.print(',');
Serial.println(IR);
red= red/IR;
green=green/IR;
blue=blue/IR;
getColor();
Serial.print(red);
Serial.print(',');
Serial.print(green);
Serial.print(',');
Serial.print(blue);
Serial.print(',');
Serial.println(color);
delay(500);
}
void getRGB()
{
uint16_t colordata= 0;
//¤³¤ÎÊդΥץí¥È¥³¥ë¤Ï¥Ç¡¼¥¿¥·¡¼¥È¤ËºÜ¤Ã¤Æ¤¤¤ë
Wire.beginTransmission(device_address);
Wire.write(control_reg);
Wire.write(0x83); // ADC reset, wakeup, low gain, fixed...
Wire.endTransmission(false);
Wire.beginTransmission(device_address);
Wire.write(control_reg);
//ADC start, wakeup, low gain, fixed time mode, 179.2ms
Wire.write(0x03);
Wire.endTransmission(true);
//probably for RGB+IR
delay(180*4); //total exposure time
Wire.beginTransmission(device_address);
Wire.write(0x03);
Wire.endTransmission(false);
Wire.requestFrom(0x2A,8,true);
//read data
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
red = colordata;
colordata =0;
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
green = colordata;
colordata =0;
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
blue = colordata;
colordata =0;
colordata = Wire.read();
colordata <<= 8;
colordata |= Wire.read();
IR = colordata;
return;
}
¾å¼ê¤¯Æ°¤¤¤¿¤¬²þÁ±¤ÏÅÔÅÙ¤·¤Æ¤¤¤¤¿¤¤¡£
*2014/4/26 OZV¤Î»È¤¤Êý [#q72fd410]
-ironeÍÑ¡£XBee¤È¤¢¤Þ¤êÊѤï¤é¤Ê¤¤¤¬¡¢¥Ñ¥±¥Ã¥È¤òºîÀ®¤·¤¿¤ê...
-¥×¥í¥°¥é¥à ~
-send¦ ~
#include <SoftwareSerial.h>
SoftwareSerial ozvSerial(10, 11); // RX, TX
//send packet, for the last 3elements, length, data and ...
byte send[10]={0xFE, 0x05, 0x2A, 0x02, 0x00, 0x00, 0x00,...
//length of data
int length = 0x01;
//data
int data = 0xCA;
int i = 0; //loop
void setup(){
Serial.begin(9600);
ozvSerial.begin(38400);
//complete send packet
send[sizeof(send) - 3] = length;
send[sizeof(send) - 2] = data;
//culculate checksum and complete send command
for(i = 1; i < sizeof(send) - 1; i++){
send[sizeof(send) - 1] = send[i] ^ send[sizeof(se...
}
}
void loop(){
//send
delay(1000);
ozvSerial.write(send,sizeof(send));
}
-receive¦ ~
#include <SoftwareSerial.h>
SoftwareSerial ozvSerial(10, 11); // RX, TX
// for the last 2elements, data and SUM
//receive packet
byte receive[12];
//data from received packet
int getData = 0x00;
//serial received data
byte receivebyte = 0x00;
int i = 0;//loop
int count = 0;//insert data into receive array
int start = 0;//start inserting
int receiveLen = 12;//receive packet length is 12
void setup(){
Serial.begin(9600);
ozvSerial.begin(38400);
}
void loop(){
//receive
if(ozvSerial.available()){
receivebyte = ozvSerial.read();
//0xFE is start of a paket
if(receivebyte == 0xFE){
start = 1;
//other than 0xFE, 11elements remaining to receive
}else if(start == 1 && count < receiveLen - 1){
receive[count] = receivebyte;
count++;
//when finished inserting, get data from the packet
}else if(count == receiveLen - 1){
count = 0;
start = 0;
getData = receive[receiveLen - 3];
Serial.print("data = ");
Serial.println(getData, HEX);
}
}
}
¾Ü¤·¤¯¤Ï˺¤ì¤¿¤Î¤Ç¥×¥í¥°¥é¥à¤À¤±¤Ç¤â˺È÷Ï¿¤È
*2014/1/10 Äɵ [#q314a404]
-ÆüËܸì¤Îencoding¤Ï¡¢%!TEX encoding = UTF-8 Unicode¤Î°ìʸ...
*2014/1/10 TeX¤òMac¤Ë¥¤¥ó¥¹¥È¡¼¥ë¡¦¥³¥Þ¥ó¥É¤Î¥Ñ¥¹¤òÄ̤¹ [...
-º£¹¹¤Ê¤¬¤é¥Þ¥Ã¥¯¤ËTeX´Ä¶¤ò¹½ÃÛ¤·¤¿¡£LaTeX¤â»È¤¨¤Æpdf¥Õ...
-sasada¤µ¤ó¤Îºî¶ÈÆü»ï¤ò¥Ò¥ó¥È¤Ë¿Ê¤á¤¿¢ªhttp://ifdl.ec.t.ka...
-¡¥¤¥ó¥¹¥È¡¼¥ë¡¦½é´üÀßÄê ~
http://d.hatena.ne.jp/lucky_pool/20120209/1328758735 ¤³¤Î...
1. Drag & Drop UpTeX ~
2. ESP Ghostscript¤Ë²Ã¤¨¤Æ¡¢~
3. UpTeXº¹Ê¬¥Õ¥¡¥¤¥ë ~
¤â¡¢¤ÈÊ̤ΤȤ³¤í¤Ç½ñ¤¤¤Æ¤¢¤Ã¤¿¤Î¤Ç¥À¥¦¥ó¥í¡¼¥É¡£3¤Ë¤Ä¤¤¤Æ...
/Applications/UpTeX.app/teTeX/bin¤Ë¥É¥é¥Ã¥°&¥É¥í¥Ã¥×¤·¤Æ...
¥µ¥¤¥È¤Ë½ñ¤¤¤Æ¤¢¤ë½é´üÀßÄê¤Ï¤·¤Æ¤ª¤¯¡£ ~
¤µ¤é¤Ë¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥óÆâ¤ÎTeXPad¤Ï¡¢°ìÅÙ¥À¥Ö¥ë¥¯¥ê¥Ã¥¯...
-¢¥Ñ¥¹¤òÄ̤¹ ~
¥³¥Þ¥ó¥É¤«¤éľÀÜ¥³¥ó¥Ñ¥¤¥ë¤ädiv¥Õ¥¡¥¤¥ë¤òºî¤ëºÝ¤Ë¤Ï¡¢¥³¥Þ...
http://xn--p8ja5bwe1i.jp/wiki/%E3%81%9D%E3%81%AE%E4%BB%96...
¤³¤Îµ»ö¤¬¤È¤Æ¤â»²¹Í¤Ë¤Ê¤ë¡£¤¿¤À¤·¡¢.bashrc¤ÎºîÀ®¤Î»ÅÊý¤È...
https://gist.github.com/disktnk/4104284 ¾åµ2¤Ä¤Î²ò·èË¡¤¬...
¤µ¤é¤Ë¡¢ÊÔ½¸¤Î»ÅÊý¤ÈÊݸ¡¦½ªÎ»¤Î»ÅÊý¤Ï ~
http://www14.plala.or.jp/campus-note/vine_linux/operation...
Íפ¹¤ë¤Ë¡¢.bashrc¤ò³«¤¤¤Æi¤ò²¡¤¹¤ÈÊÔ½¸²èÌ̤ˤʤꡢ¥³¥Þ¥ó...
¤³¤³¤Þ¤Ç¤¬½ª¤ï¤ë¤È¥Ñ¥¹¤Î³Îǧ¤ò¤¹¤ë¡£¥¿¡¼¥ß¥Ê¥ë¤Ë¡¡platex ...
¤¢¤È¤Ï¥Á¥å¡¼¥È¥ê¥¢¥ëhttp://www.comp.tmu.ac.jp/tsakai/lect...
platex sample.tex
¤Ç¥¨¥é¡¼¤¬¤Ê¤±¤ì¤Ðdvi¥Õ¥¡¥¤¥ë¤¬¤Ç¤¤Æ¡¢ ~
dvipdfmx sample.dvi ~
¤Çpdf¥Õ¥¡¥¤¥ë¤¬¤Ç¤¤ë¡£ ~
*2013/12/8 RFM12B(Èù¼å̵Àþ¥â¥¸¥å¡¼¥ë)¤ò»È¤Ã¤Æ¤ß¤¿ [#y7e8e...
-ÀèÀ¸¤Ë夤¤¿¥é¥¤¥Ö¥é¥ê¤ò¤¤¤¸¤Ã¤Æ¤ß¤¿
-̤´°À®Éôʬ(Åž춯Å٤η׻»¡¦ironeÍѤ˴°Á´arduino UNOÈ´¤...
-´°À®Éôʬ(¥Ç¡¼¥¿¤ÎÁ÷¿®¡¦¼õ¿®)
-SPIÄÌ¿®¤Ë¤è¤Ã¤ÆÀ©¸æ¤¹¤ë¡£
¡½àÈ÷¡§
¥Ç¡¼¥¿¥·¡¼¥È
http://www.hoperf.com/upload/rf/rfm12b.pdf
¥³¥Þ¥ó¥É
http://www.hoperf.com/upload/rf/rfm12b.pdf
¥³¥Þ¥ó¥ÉÁḫɽ¡¡
http://tools.jeelabs.org/rfm12b.html
http://www.sevenwatt.com/main/
ÅÅÇȶ¯ÅÙ¡¡
http://eleclog.quitsq.com/2011/11/rfm12b-radio-act.html
Arduino cookbook
https://www.inkling.com/read/arduino-cookbook-michael-mar...
¥Ñ¥±¥Ã¥ÈÆâÍÆ¡¡
http://lowpowerlab.com/blog/2012/12/28/rfm12b-arduino-lib...
http://lowpowerlab.com/blog/2013/06/20/rfm69-library/
http://jeelabs.org/2011/12/11/inside-the-rf12-driver-part...
2¿Ê¿ô·×»»¡¡
http://hogehoge.tk/tool/number.html
Arduino¥Ô¥óÇÛÃÖ¡¡
http://wiki.onakasuita.org/pukiwiki/?Arduino%2F%E3%83%94%...
¢²óÏ©¡§
#ref(rfm_1.png)
º£²ó¤Ï¤³¤ì¤é¤Ë²Ã¤¨¤ÆnINT/VDI, FSK/DATA/nFFS, DCLK/CFIL/FF...
Arduino UNO¤Ï5V¤ÇÆ°ºî¤¹¤ë¤Î¤Ç¡¢RFM12B¤ËÆþ¤ë¿®¹æ¤òʬ°µ¤¹¤ë...
£¥é¥¤¥Ö¥é¥ê¡§
-RF12.cpp
/*useful command: http://tools.jeelabs.org/rfm12b.html
arduino¤ò»ÈÍѤ¹¤ë¤È¤¤Ï16MHz¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç/4(¥Ç¥Õ¥©¥ë...
#define arduino
ÀèÀ¸¤Î¥é¥¤¥Ö¥é¥ê¤«¤éÊѹ¹¤·¤¿²Õ½ê */
#define changed
/*commands*/
#define SET_TX 0x8279
#define SET_RX 0x82D9
#define RESET 0x0000
#define STATUS_CHECK 0x0000
#define TX_SEND 0xB800 //+ data
#define RX_RECEIVE 0xB000
#define CONFIGURATION 0x80D7 // el(enable tx regigter),...
#define SET_FREQUENCY 0xA4B0 // 433MHz
#define SET_DATARATE 0xC623 // 9.6kbps
#define SET_PLL 0xCC17 // CLK=2.5MHz, !ddy ddit, PLL BW...
#define RX_CONTROL 0x94C2 // VDI,FAST,67kHz,LNA=0dBm,RS...
#define Data_Filter_Clock_Recovery 0xC2AC // AL,!ml,DIG...
#define FIFO_RESET_MODE 0xCA83 // FIFO8,2byte-SYNC,!AL,...
#define TX_CONTROL 0x9850 // !mp,90kHz,MAX OUT TXpower=...
#define AUTO_FREQUENCY_CONTROL 0xC483 // @PWR,NO RSTRIC...
#define SET_WAKEUP_TIMER 0xE000 // wake up timer / NOT ...
#define SET_LOW_DUTY_CYCLE 0xC800 // low duty cycle / N...
#define SET_LOW_BATTERY_DETECT_uC_CLK 0xC049 // 1.66MHz...
#define SET_SYNC_PATTERN 0xCED4 // SYNC=2DD4
//status
#define TX_READY 0x8000
#define FIFO_REACHED 0x8000
//pin
#define SPI_MOSI 11
#define SPI_MISO 12
#define SPI_SCK 13
#include <pins_arduino.h>
#include <avr/interrupt.h>
#include <Arduino.h>
#include <RF12.h>
int nIRQ_pin, SS_pin, RST_pin;
int mode;
uint8_t RF12::spi_byte(uint8_t out) {
SPDR = out;
while (!(SPSR & _BV(SPIF)));
return SPDR;
}
uint16_t RF12::xfer_byte(uint16_t cmd)
{
uint16_t dat = 0;
digitalWrite(SS_pin, 0);
dat = spi_byte(cmd >> 8) << 8;
dat |= spi_byte(cmd);
digitalWrite(SS_pin, 1);
return(dat);
}
void RF12::send_byte(byte data)
{
uint16_t d;
// while(!((d = xfer_byte(0x0000)) & 0x8000)) Serial.p...
//send 0000(status check). when returned 8000 TX is ready
while(!(xfer_byte(STATUS_CHECK) & TX_READY)); // wait f...
xfer_byte(TX_SEND + data);
delay(1);
}
//sending 1bit per time
//would I need this?
void RF12::send_data(byte *data, byte len)
{
byte cksum = 0;
for (int i = 0; i < len; i++){
send_byte(data[i]);
cksum += data[i];
}
send_byte(cksum);
}
//wait(blocks) until it receives -> it's okay cuz used ...
#ifdef changed
byte RF12::receive_byte()
{
//interrupt request output(from RFM12B), active low
while(digitalRead(nIRQ_pin) == 1); // wait for any data ...
//status check, reset functions
//xfer_byte(0x0000);
// while(!(xfer_byte(0x0000) & 0x8000))Serial.println(x...
//read 8 bits from the receiver FIFO (even if FIFO not ...
xfer_byte(RESET);
return(xfer_byte(RX_RECEIVE));
}
#else
byte RF12::receive_byte()
{
//interrupt request output(from RFM12B), active low
while(digitalRead(nIRQ_pin) == 1); // wait for any data...
//status check, reset functions
xfer_byte(0x0000);
//read 8 bits from the receiver FIFO (even if FIFO not ...
return(xfer_byte(0xB000));
}
#endif
//needed to recaive less than a byte?
byte *RF12::receive_data(byte *data, byte len)
{
int i;
for (i = 0; i < len; i++){
data[i] = receive_byte();
}
return(data);
}
void RF12::begin(uint8_t nIRQ, uint8_t SS, uint8_t RST)
{
nIRQ_pin = nIRQ;
SS_pin = SS;
RST_pin = RST;
pinMode(RST_pin, INPUT);
// digitalWrite(RST_pin, 0);
digitalWrite(SS_pin, 1);
pinMode(SS_pin, OUTPUT);
//digital 11,12,13 is fixed
//faster when set it directly?
#ifdef changed
DDRB |= ((1<<DDB3)|(1<<DDB4)|(1<<DDB5));
#else
pinMode(SPI_MOSI, OUTPUT);
pinMode(SPI_MISO, INPUT);
pinMode(SPI_SCK, OUTPUT);
#endif
//need to make this smaller than 2.5MHz? arduino is 16MHz
SPCR = _BV(SPE) | _BV(MSTR); // SPI master enable, Mode0
#ifdef arduino
SPSR |= _BV(SPI2X);
#endif
pinMode(nIRQ_pin, INPUT);
digitalWrite(nIRQ_pin, 1); // pull-up, active low
//status check for return and initialization
xfer_byte(RESET); // intitial SPI transfer added to avo...
// wait until RFM12B is out of power-up reset, this tak...
//empty Tx buffer
xfer_byte(TX_SEND); // in case we're still in OOK mode
//reset again and again
while (digitalRead(nIRQ_pin) == 0) xfer_byte(RESET);
//yes, commands start
//enable internal register and FIFO mode ---> why? need...
xfer_byte(CONFIGURATION); // el, ef 12.0pF, 433MHz
//fastest way it might be: turning on the whole receive...
//I don't understand here according to datasheet
#ifdef changed
xfer_byte(0x82d9); // RX mode -> in case didn't set the...
xfer_byte(SET_FREQUENCY); // 433MHz
xfer_byte(SET_DATARATE); // 9.6kbps
xfer_byte(SET_PLL); // CLK=2.5MHz, !ddy ddit, PLL BW=256k
//especially here
//xfer_byte(TX_CONTROL); // !mp,90kHz,MAX OUT TXpower=0...
xfer_byte(RX_CONTROL); // VDI,FAST,67kHz,LNA=0dBm,RSSI=...
#else
//receiver baseband circuite separately switched on
xfer_byte(0x82d9); // RX mode -> in case didn't set the...
xfer_byte(0xA640); // 437MHz (430+0.0025*(0x640)[MHz])
xfer_byte(0xC647); // 4.8kbps
xfer_byte(0xCC77); // CLK=2.5MHz, !ddy ddit, PLL BW=256k
xfer_byte(0x94A2); // VDI,FAST,134kHz,LNA=0dBm,RSSI=-91...
#endif
//Data Filter & Clock Recovery
xfer_byte(Data_Filter_Clock_Recovery); // AL,!ml,DIG,DQ...
//FIFO and reset mode
xfer_byte(FIFO_RESET_MODE); // FIFO8,2byte-SYNC,!AL,ff,...
//Automatic Frequency Control
xfer_byte(AUTO_FREQUENCY_CONTROL); // @PWR,NO RSTRIC,!s...
//replaced---------------------------------------------...
//TX control
xfer_byte(TX_CONTROL); // !mp,90kHz,MAX OUT TXpower=0(m...
//-----------------------------------------------------...
xfer_byte(SET_WAKEUP_TIMER); // wake up timer / NOT USE
xfer_byte(SET_LOW_DUTY_CYCLE); // low duty cycle / NOT ...
//Low Battery Detect and µC Clock
xfer_byte(SET_LOW_BATTERY_DETECT_uC_CLK); // 1.66MHz,3....
//Synchronization Pattern
xfer_byte(SET_SYNC_PATTERN); // SYNC=2DD4
delay(1);
}
void RF12::set_tx_power(uint8_t pow)
{
//just setting the power on TX Configuration Command
xfer_byte(TX_CONTROL + (pow & 0x07));
}
uint16_t RF12::read_status(void)
{
return(xfer_byte(STATUS_CHECK));
}
RF12::RF12(void)
{
}
void RF12::set_mode(uint8_t md)
{
mode = md;
// xfer_byte(0x8239); // !er, !ebb, et, es, ex, !eb, ...
// xfer_byte(0x82D9); // er, ebb, !et, es, ex, !eb, ...
//new--------------------------------------------------...
//xfer_byte(0x8279); // !er, ebb, et, es, ex, !eb, !ew,...
// xfer_byte(0x82D9); // er, ebb, !et, es, ex, !eb, !...
#ifdef changed
if (md == RF12_MODE_TX) xfer_byte(SET_TX);
else if (md == RF12_MODE_RX) xfer_byte(SET_RX);
#else
if (md == RF12_MODE_TX) xfer_byte(0x8239);
else if (md == RF12_MODE_RX) xfer_byte(0x82d9);
#endif
}
int RF12::available(void)
{
if (digitalRead(nIRQ_pin) == 0) return(1);
else return(0);
}
-Á÷¼õ¿®¤Îino¥Õ¥¡¥¤¥ë
Rx:
#include <RF12.h>
int RF12_SS = 10;
int RF12_nIRQ = 9;
int RF12_RST = 8;
uint8_t payload[16];
uint16_t pckt;
RF12 rf12 = RF12();
byte data;
byte packet[16];
void setup()
{
Serial.begin(9600);
rf12.begin(RF12_nIRQ, RF12_SS, RF12_RST);
rf12.set_mode(RF12_MODE_RX);
Serial.println("Ready Rx");
}
int header = 4;
int tail = 6;
int index = 0, check = 0;
void loop()
{
//uint8_t c;
if (rf12.available()){
data = rf12.receive_byte();
if((data == 0xAA) || (data == 0x55)) ; else Serial.writ...
}
//Serial.println();
}
Tx:
#include <RF12.h>
int RF12_SS = 10;
int RF12_nIRQ = 9;
int RF12_RST = 8;
uint16_t payload[16];
uint16_t c;
RF12 rf12 = RF12();
void setup()
{
Serial.begin(9600);
pinMode(4, OUTPUT);
rf12.begin(RF12_nIRQ, RF12_SS, RF12_RST);
rf12.set_mode(RF12_MODE_TX);
Serial.println("TX ready");
c = '!';
}
void loop()
{
//packet format - only activating necessary parts for ju...
//see http://jeelabs.org/2011/12/11/inside-the-rf12-driv...
//or http://lowpowerlab.com/blog/2012/12/28/rfm12b-ardui...
//for full packet information
//necessary part(5 bytes)
//preamble
rf12.send_byte(0xAA);
rf12.send_byte(0xAA);
rf12.send_byte(0xAA);
//SYN-ox2d
rf12.send_byte(0x2D);
//SYN-network ID (network group (can be in the range 1-2...
rf12.send_byte(0xD4);
//header
//CTLflag + DestID(unique node ID of receiver (1 through...
//0 + 55
//rf12.send_byte(c);
rf12.send_byte(0x55);
//ACK + SourceID(unique node ID of receiver (1 through 3...
//1 + 42?
rf12.send_byte(0xaa);
//DataLength
rf12.send_byte(0x55);
//Data
rf12.send_byte(0xaa);
rf12.send_byte(c); //CRC
rf12.send_byte(c+1);
rf12.send_byte(c+2);
rf12.send_byte(0x55);
//CRC
rf12.send_byte(0xaa);
rf12.send_byte(0x55);
rf12.send_byte(0xaa);
rf12.send_byte(0xaa);
rf12.send_byte(0xaa);
//Serial.println("Sent.");
digitalWrite(4, HIGH);
delay(250);
digitalWrite(4, LOW);
delay(250);
//}
}
Ãí°Õ¡§Serial.print¤ò»È¤¦¤ÈSerial¤¬¥Ï¥¤¤Ë¤Ê¤Ã¤Æ¤¤¤ë»þ¤Ë²¿...
100²ó¤Ë1²ó¤°¤é¤¤Ãͤò´Ö°ã¤¨¤ë¤³¤È¤¬¤¢¤ë¡£
¾åµ¥×¥í¥°¥é¥à¤ÎºÙ¤«¤¤ÆâÍƤˤĤ¤¤Æ¤Ï¸å¤Û¤É¹¹¿·Í½Äê
*2013/12/8 Serial.print¤ÈSerial.write [#hdc93cf4]
-»²¹Í: http://arduino.cc/en/Serial/write
1byte¤¢¤ë¤¤¤Ï¤½¤ì°Ê¾å¤Î¥Ð¥¤¥Èñ°ÌËè¤Ë¡¢Serial.write¤Ï¥Ð¥¤...
*2013/9/30 unsigned¤Ëµ¤¤ò¤Ä¤±¤ë [#m66236ad]
-¤¿¤À¤Îint¤Ç-¤¬¤Ä¤¯¤Î¤ÏÃͤ¬Â礤¤¾ì¹ç
*2013/9/26 ATmega3238P¥Ö¡¼¥È¥í¡¼¥À¸å¤Î¥¹¥±¥Ã¥Á½ñ¤¹þ¤ß¥á...
-¥ê¥»¥Ã¥È¥¹¥¤¥Ã¥Á¤Ë¤Ä¤±¤ë¥³¥ó¥Ç¥ó¥µ¤Ï0.1¦ÌF¤À¤È¾å¼ê¤¯¤¤¤¯...
* 2013/9/24 ATmega328P¤Î¥Ö¡¼¥È¥í¡¼¥À¡¼½ñ¤¹þ¤ß¥á¥â(PU) [#...
-¥Ò¥å¡¼¥ºÀßÄêɽ
#ref(3_1.png)
-¤É¤Î¥Ö¡¼¥È¥í¡¼¥À¡¼¤ò»È¤¦¤«¤Ïbootloader.txt¤ËºÜ¤Ã¤Æ¤¤¤ë
-ATmega328p¤Ç¤Ïhttp://ifdl.ec.t.kanazawa-u.ac.jp/~akita/l...
#ref(3_2.png)
-¼ê½ç(µð¾¢¤µ¤ó¤Îºî¶ÈÆü»ï¤â»²¹Í¤Ë¤µ¤»¤Æĺ¤¤Þ¤·¤¿¡£)
-¿Þ¤¬¤¿¤¯¤µ¤ó¤Çʬ¤«¤ê¤ä¤¹¤¤¡¢¡¢¡¢
-http://mizupc8.bio.mie-u.ac.jp/pukiwiki/index.php?Arduin...
* 2013/9/23 ˺È÷Ï¿-Sparkfun.com MP3 Player Shield¤ò»È¤¦»þ...
-Sparkfun.com MP3 Player Shield¤òUNO¤Ç»È¤¦»þ¤Ë¥¤¥ó¥¹¥È¡¼...
-https://www.sparkfun.com/tutorials/295 ¤Î
#ref(2_1.png)
¡¡¤¬Â¸ºß¤·¤Ê¤¤¤Î¤Ç¤¹¤¬¡¢Arduino/libraries/SdFat/SdFatConf...
#ref(2_2.png)
¡¡¤Ë¤¢¤ê¤Þ¤·¤¿¡£¤³¤³¤ÎCS¤ò10¢ª9¤ËÊѤ¨¤ë¤ÈÆ°¤¤Þ¤·¤¿¡£
* Eclipse¤ò»È¤Ã¤ÆJava¤Ç¥·¥ê¥¢¥ëÄÌ¿® [#ga87d6a8]
- Æ°ºî´Ä¶¡§Windows7 64bit
- ¼ê½ç
¡¥·¥ê¥¢¥ëÄÌ¿®¤ò¹Ô¤¤¤¿¤¤Eclipse¤Îpackage²¼¤ËÄɲå饤¥Ö¥é...
#ref(1.png)
¢ÄɲÃÍѤΥ饤¥Ö¥é¥ê¤ò¥¤¥ó¥¹¥È¡¼¥ë
-- http://mfizz.com/oss/rxtx-for-java
¡¡¡¡¤³¤Î¥Õ¥©¥ë¥À¤ò²òÅष¤¿Ãæ¤Î¡¢
¡¡¡¡¡¡rxtxParallel.dll
¡¡¡¡¡¡rxtxSerial.dll
¡¡¡¡¡¡RXTXcomm.jar
¡¡¡¡¤ò¥³¥Ô¡¼¤·¤Æ¡¢¡¤Î¥Õ¥©¥ë¥ÀÆâ¤Ë¥Ú¡¼¥¹¥È
-¤â¤·¤â¥Ñ¥½¥³¥ó¼«ÂΤ˥¤¥ó¥¹¥È¡¼¥ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢Program Fi...
£Eclipse¤ÇLibrary Path¤òÄɲ乤ë
-Eclipse¤òµ¯Æ°
-¤Þ¤º¡¢¿·¤·¤¯ºî¤Ã¤¿¥Õ¥©¥ë¥À¤¬Æþ¤Ã¤Æ¤¤¤ëPackage̾¤ò±¦¥¯¥ê...
¡¡¡¡
¤³¤ì¤Ç¡¢¿·¥Õ¥©¥ë¥À¤¬Package¤ËÃç´ÖÆþ¤ê¡£
¡¡
-Project¥¿¥Ö¤ÎProperties¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¡£Properties¤Îº¸¤ËJ...
-Libraries¥¿¥Ö¤ò¥¯¥ê¥Ã¥¯¡£Add Jars...¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¡¢¡¤Ç...
#ref(2.png)
-¤³¤ì¤ÇÀßÄê¤Ï´°Î»¡£¤¢¤È¤Ï¥×¥í¥°¥é¥à¤ò½ñ¤¯¤Î¤ß¡£
¤¥×¥í¥°¥é¥àºîÀ®
-CommLight.java¡Ê¥á¥¤¥ó¤¬¤¢¤ë¥Õ¥¡¥¤¥ë¡Ë
//port check
//JDK check
import java.io.*;
public class CommLight{
static File sharedText;
public static void main(String[] args){
SerialComm serialcomm = new SerialComm();
serialcomm.open();
int i = 10;
while(i>0){
serialcomm.write((byte)0x34);
try{
Thread.sleep(500);
}catch(Exception e){
}
serialcomm.write((byte)0x20);
try{
Thread.sleep(500);
}catch(Exception e){
}
serialcomm.write((byte)0x78);
try{
Thread.sleep(500);
}catch(Exception e){
}
i--;
}
System.out.println("Hello, World");
}
}
-SerialComm.java
import gnu.io.*;
import java.io.*;
import java.util.*;
public class SerialComm implements SerialPortEventListe...
private SerialPort port;
// private static BufferedReader reader;
private InputStream in;
private OutputStream out;
SerialComm(){
super();
}
public void open(){
try {
// Serial port initialize
CommPortIdentifier portId = CommPortIdentifier.getPort...
port = (SerialPort)portId.open("USB Serial Port", 2000);
port.setSerialPortParams(
9600, // í êM롯ìx[bps]
SerialPort.DATABITS_8, // ÉfÅ[É^...
SerialPort.STOPBITS_1, // ÉXÉgÉb...
SerialPort.PARITY_NONE // ÉpÉäÉ...
);
port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
try{
port.addEventListener(this);
port.notifyOnDataAvailable(true);
in = port.getInputStream();
out = port.getOutputStream();
}catch(TooManyListenersException ex){
System.out.println("Error1: "+ex);
}
} catch (Exception e) {
System.out.println("Error2: " + e);
System.exit(1);
}
}
public void close(){
try{
in.close();
out.close();
port.close();
}catch(Exception e){
System.out.println("close: "+e);
}
}
public void read(){
try{
byte[] buffer;
int temp = in.available();
if(temp>0){
System.out.println("temp: "+temp);
buffer = new byte[temp];
temp = in.read(buffer);
int num = 0;
while(num<temp){
System.out.println("b "+num+": "+Integer.toHexString...
num++;
}
}
in.close();
}catch(Exception e){
System.out.println("error4: "+e);
}
}
public static String toHex(byte[] digest) {
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%1$02X", b));
}
return sb.toString();
}
public void write(byte data){
try{
out.write((byte)data);
out.flush();
//ÉXÉgÉäÅ[ÉÄÇ&...
}catch(Exception e){
System.out.println("port exception: "+e);
}
}
public void run() {
try {
InputStreamReader isr = new InputStreamReader(System.i...
BufferedReader br = new BufferedReader(isr);
OutputStream out = port.getOutputStream();
boolean flagQuit = false;
while (!flagQuit) {
String input = br.readLine();
if (input.length() > 0) {
if (input.equals(":quit"))
break;
input += "\r";
out.write(input.getBytes("US-ASCII"));
}
}
port.close();
} catch (Exception e) {
System.out.println("Error3: " + e);
}
}
public void serialEvent(SerialPortEvent event) {
if (event.getEventType() == SerialPortEvent.DATA_AVAILA...
read();
}
}
}
¥´°À®
¥Ú¡¼¥¸Ì¾: