LCDにネットワーク情報を出力する
/* The circuit: * LCD RS pin to digital pin 8 * LCD Enable pin to digital pin 9 * LCD D4 pin to digital pin 4 * LCD D5 pin to digital pin 5 * LCD D6 pin to digital pin 6 * LCD D7 pin to digital pin 7 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) */ // include the library code: #include <LiquidCrystal.h> #include <Ethernet.h> byte mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x00}; IPAddress defip(192,168,0,200); IPAddress dnsserver(192,168,0,0); IPAddress gateway(192,168,0,1); IPAddress subnet(255,255,255,0); // initialize the library with the numbers of the interface pins LiquidCrystal lcd(8, 9, 4, 5, 6, 7 ); void printIP(IPAddress ip){ int i; for( i = 0; i < 4; i++){ lcd.print(ip[i]); if(i < 3){ lcd.print('.'); } } } void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); Ethernet.begin(mac,defip,dnsserver, gateway, subnet); } void loop() { lcd.clear(); printIP(Ethernet.localIP()); lcd.setCursor(0,1); printIP(Ethernet.dnsServerIP()); delay(1000); lcd.clear(); printIP(Ethernet.gatewayIP()); lcd.setCursor(0,1); printIP(Ethernet.subnetMask()); delay(1000); }
とりあえず、Ethernetクラスに設定した値を出力するものを作成。
本当はlinuxの設定を読み取って表示をしたかったが、linuxコマンドの実行結果の取得法が分からず断念。
(手間なので適当なファイルに書き込んで読み込みはやらなかった)