Software apps and online services
Hand tools and fabrication machines
Inspired by the new Avengers Movie, I started working on a 3D-printed Thanos Infinity Gauntlet. I installed neopixel RGB LEDs for each of the Infinity stones in this 3D model. The lighting up/dimming pattern of these Infinity stone LEDs is controlled by the movement of the gauntlet detected using an accelerometer, which is interfaced with the NXP LPCXpresso804 development board.Construction
The Infinity Gauntlet is 3D-printed along with all the Thanos' 6 Infinity stones using the attached 3D-printing libraries. The LPCXpresso804 board and the rest of the hardware is installed inside this gauntlet.
The NXP LPC804 master board is interfaced with the slave MMA8652 accelerometer sensor board via I2C protocol (using SDA, SCL lines with internal pull-up resistors). A string of Neopixel LEDs run through each 3D printed Infinity stones. The Neopixel LEDs are interfaced using SPI protocol. Serial data based on the desired pattern is transferred from the LPC804 board to these RGB LEDs.
The NXP board has a battery slot which holds a coin cell battery for all portable applications (while using the coin cell battery switch S4 on the board must be closed to connect the battery).
The accelerometer acts as a I2C slave device in this application with slave address: 0x1D. Position of the gauntlet is determined by the x, y, z-axis values obtained from this slave device. The change in these x, y, z values helps determine the movement of the gauntlet. We can assign various patterns to the RGB LEDs for each movement. Each LED can display different colors based on the combination of its Red-Green-Blue components.
When the accelerometer is rotated along the x-axis from left to right, the brightness of all the LEDs increase gradually. Extreme right accelerometer position being the brightest. On the other hand, when the accelerometer is rotated along the x-axis from right to left, LEDs light up one by one depending on the x-angle value. All LEDs lit up at the extreme left accelerometer position.Hardware Connections
The NXP MMA8652 3-axis accelerometer on the breakout board can be connected using I2C protocol. SCL, SDA lines and can be powered via VVD VDDIO and GND pins.
Connect pins of I2C master and slave as below:
Neopixel RGB LEDs are powered with supply voltage of +5V and has a serial data pin as input.
Connect pins of LPCXpresso804 board and Neopixel LED(WS2812) strip:
The LPCXpresso804 board has a SDK package support which is really great! I used the SPI and I2C SDK driver APIs in the software for interfacing the hardware components in this project.
The MCUXpresso SDK Builder has open source drivers, middleware, and reference example applications for software development. Customize and download the SDK specific to the processor and then import the zip file to the project in MCUXpresso IDE.
PLU tool helps defining inputs and outputs (board comes with a PLU shield). The PLU tool generates the following C code for setting up PLU configuration registers:
PLU->LUT.INP = 0x00000003; // IN3 (SEL) PLU->LUT.INP PLU->LUT.INP = 0x00000001; // IN1 (BIT0) PLU->LUT.INP PLU->LUT.INP = 0x00000002; // IN2 (BIT1) PLU->LUT.INP PLU->LUT.INP = 0x0000003F; // default PLU->LUT.INP PLU->LUT.INP = 0x0000003F; // default PLU->LUT.INP PLU->LUT_TRUTH = 0x1b1b1b1b; // Selector (Selector) CUSTOM PLU->LUT.INP PLU->OUTPUT_MUX = 0x00000000; // LUT0 (Selector)-> WS2812_DATA PLU->LUT.INP PLU->OUTPUT_MUX = 0; //PLU_OUT1 = LUT
The LPCXPresso804 also features function-configurable I/O ports through a switch matrix (SWM). This makes it easier to configure pin routing and other pin electrical features:
/* USART0_TXD connect to P0_4 */ SWM_SetMovablePinSelect(SWM0, kSWM_USART0_TXD, kSWM_PortPin_P0_4); /* USART0_RXD connect to P0_0 */ SWM_SetMovablePinSelect(SWM0, kSWM_USART0_RXD, kSWM_PortPin_P0_0); /* I2C0_SDA connect to P0_7 */ SWM_SetMovablePinSelect(SWM0, kSWM_I2C0_SDA, kSWM_PortPin_P0_7); /* I2C0_SCL connect to P0_14 */ SWM_SetMovablePinSelect(SWM0, kSWM_I2C0_SCL, kSWM_PortPin_P0_14);
Turning On the LEDs for assigned color and brightness level:
WS2812_OUTLVL = xAngle/2; LED_color(WS2812_OUTLVL, Power_Yellow); LED_color(WS2812_OUTLVL, Reality_Orange); LED_color(WS2812_OUTLVL, Mind_Red); LED_color(WS2812_OUTLVL, Time_Blue); LED_color(WS2812_OUTLVL, Soul_Purple); LED_color(WS2812_OUTLVL, Space_Green); start_transfer(1);