温度2バイト読み取り STARTコンディション アドレス0x91 DATA(MSB) DATA(LSB) STOPコンディション |
温度12ビットに設定 STARTコンディション アドレス0x90 1を書き込み 0x60を書き込み STOPコンディション |
温度読み取りモードに戻す STARTコンディション アドレス0x90 0を書き込み STOPコンディション |
/* Temp1_2210 board:NANOno1 16MHz 3.3V LCD 3.3V fuse: FF DF FD FD=101=2.7V BOD (FC=4.3V) */ #include <LiquidCrystal.h> #include <Wire.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //rs, en, d4, d5, d6, d7 //縲val int i; uint8_t tp[3]; // tp[]:TEMPdata char s[15]; // string for print & input void setup() { lcd.begin(16, 2); lcd.print("hello, world!"); Wire.begin(0x90 >> 1); // 温度センサーDS7505 // 温度センサー12ビット読み取りに設定 Wire.beginTransmission(0x90>>1); Wire.write(0x01); // inner=01 set mode9bit or 12bit Wire.write(0x60); delay(300); // set 12bit mode Wire.endTransmission() ; delay(20); // 温度センサーデータ読み取りモードに戻す Wire.beginTransmission(0x90>>1); Wire.write(0x00); delay(10); // inner=00 set mode read data Wire.endTransmission() ; delay(20); void loop() { //以下温度処理 Wire.requestFrom(0x90>>1,2); // デバイス(address 0x90>>1)に対し2バイト読み出しを要求 i=1; while(Wire.available()) { // 要求より短いデータが来る可能性あり tp[i] = Wire.read(); // 1バイトを受信 i++; } //温度表示 s[1]=tp[1]/10+0x30; s[2]=tp[1]%10+0x30; s[3]='.'; s[4]=(((tp[2]/16)*10)/16)+0x30; s[5]=' '; lcd.setCursor(11,1); for(i=1;i<6;i++){lcd.print(s[i]);} //配列は設定できない //以上、温度処理・表示 delay(1000); lcd.setCursor(0, 1); lcd.print(millis() / 1000); }
/* blink0-221102 mc:ESPWROOM02 * borad:GenericESP6Module */ void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(16, OUTPUT); pinMode(12, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(12, LOW); delay(500); digitalWrite(16, LOW); digitalWrite(12, HIGH); delay(1000); }8266WROOM02 2 I2C_LCD_TEST MC:ROOM02 3.3V
/* i2c_crt_test_221103 mc:ESPWROOM02 3.3V borad:GenericESP6Module */ #include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { // initialize the LCD lcd.begin(); // Turn on the blacklight and print a message. lcd.backlight(); lcd.print("Hello"); delay(1000); lcd.clear(); } void loop() { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Hello,world!"); delay(1000); lcd.setCursor(0, 1); lcd.print("0123456789012345"); delay(1000); lcd.clear(); lcd.setCursor(1, 1); lcd.print("ABCDefgh"); delay(1000); }