-- Kitt Car Modified by John Longworth December 2017 -- Using pins 3 & 4 to be compatible with ESP001 -- SDA & SDL can be assigned any pin number between 1 - 12 -- Connects to MCP23008 (8-Bit I/O Expander with Serial Interface) -- Uses mcp23008.lua - This file must be in the ESP8266 memory local i = 1 local dir = 1 mcp = require ("mcp23008") id = 0x00 -- Always 0 sda = 3 -- GPIO0 Connect to Pin 2 of MCP23008 scl = 4 -- GPIO2 Connect to Pin 1 of MCP23008 mcp.begin(id,sda,scl,i2c.SLOW) mcp.writeIODIR(0x00) -- Set all GPIO pins as outputs tmr.alarm(1,250,1,function() print("I = " .. i) mcp.writeGPIO(i) dir = (i == 1) and (dir == -1) and 1 or (i == 128) and (dir == 1) and -1 or dir i = (dir == 1) and i * 2 or i / 2 end)