I2C1.setup({scl:NodeMCU.D5, sda:NodeMCU.D4}); var lcd = require("HD44780").connectI2C(I2C1); lcd.print("Hello World!"); lcd.setCursor(0,1); lcd.print("ESP8266!"); /* I2C1 SPI1 NodeMCU.D1 D5 GPIO5 NodeMCU.D2 D4 GPIO4 NodeMCU.D3 D0 GPIO0 FLASHBTN / Built in LED NodeMCU.D4 D2 GPIO2 SDA Debug Serial - RX1 on FTDI chip NodeMCU.D5 D14 GPIO14 SCL CLK NodeMCU.D6 D12 GPIO12 MISO NodeMCU.D7 D13 GPIO13 MOSI NodeMCU.D8 D15 GPIO15 CS NodeMCU.D9 D3 GPIO3 NodeMCU.D10 D1 GPIO1 NodeMCU.A0 D0 GPIOx */ //1011101111110000 101010000 10001111 /* Apple white remote 33 bits - spaces added 10111011111100001 0101 000010001111 up 10111011111100001 1001 000010001111 left 10111011111100001 1010 000010001111 play 10111011111100001 0110 000010001111 right 10111011111100001 0011 000010001111 down 10111011111100001 1100 000010001111 menu longer codes - last 1's are button repeats */ var button={5:'up',9:'left',10:'play',6:'right',3:'down',12:'menu'}; require("IRReceiver").connect(NodeMCU.D1, function(code) { console.log(code); if ( code.length >= 33 ) { var l=parseInt(code.slice(1,16),2); if ( l === 15344 ) { lcd.setCursor(0,1); var k=parseInt(code.slice(17,21),2); console.log({k:k,b:button[k]}); lcd.clear(); lcd.print(button[k]); } } });
10111011111100001100100001000111111 { "k": 9, "b": "left" } 10111011111100001010100001000111111 { "k": 5, "b": "up" } 101110111111000010011000010001111 { "k": 3, "b": "down" } 101110111111000011010000010001111 { "k": 10, "b": "play" } 101110111111000010110000010001111 { "k": 6, "b": "right" } 10111011111100001110000001000111111 { "k": 12, "b": "menu" }
@Wilberforce started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.