Yuancong Jing Rex glove

“Hand Glove REX From Naruto Pain ”

In the transcendent world of “Naruto”, the character Pain (Pein), particularly his manifestation as Shurado , presents a fascinating amalgamation of mystic lore and mechanized warfare.

Drawing inspiration from this iconic figure, we introduce “Rex” – a hand glove design project that transcends the boundary between the fictional realm and practical application

sketches for the design concept

The Part list:

  • Flex sensor * 1.
  • 10k Orm resist
  • Led Board Number*8
  • Lead circle board * 7
  • Adafruit Gemma Mo
  • Jumper electric wire
  • electric wire * 8

Code

#include <Adafruit_NeoPixel.h>

#define FLEX_PIN A1
#define LED_PIN 1
#define LED_COUNT 60
#define MAX_BRIGHTNESS 150

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

int lastFlexPosition = 0;
int state = 0;
unsigned long lastBlinkTime = 0;
const int blinkInterval = 100;

void setup() {
  strip.begin();
  strip.setBrightness(MAX_BRIGHTNESS);
  strip.show();
}

void loop() {
  int flexPosition = analogRead(FLEX_PIN);

  if (lastFlexPosition > 650 && flexPosition <= 650) {
    state = (state + 1) % 7;
  }

  lastFlexPosition = flexPosition;

  int litLEDs = map(flexPosition, 550, 800, 0, LED_COUNT);
  litLEDs = constrain(litLEDs, 0, LED_COUNT);

  switch (state) {
    case 0: setStripColor(litLEDs, strip.Color(255, 0, 0)); break;
    case 1: setStripColor(litLEDs, strip.Color(0, 0, 255)); break;
    case 2: setStripColor(litLEDs, strip.Color(0, 255, 0)); break;
    case 3: blinkStrip(litLEDs, strip.Color(255, 0, 0)); break;
    case 4: blinkStrip(litLEDs, strip.Color(0, 0, 255)); break;
    case 5: blinkStrip(litLEDs, strip.Color(0, 255, 0)); break;
    case 6: randomBlink(litLEDs); break;
  }

  strip.show();
}

void setStripColor(int litLEDs, uint32_t color) {
  for (int i = 0; i < LED_COUNT; i++) {
    uint32_t dimmedColor = dimColor(color);
    strip.setPixelColor(i, i < litLEDs ? dimmedColor : strip.Color(0, 0, 0));
  }
}

void blinkStrip(int litLEDs, uint32_t color) {
  unsigned long currentMillis = millis();

  if (currentMillis - lastBlinkTime > blinkInterval) {
    lastBlinkTime = currentMillis;
    for (int i = 0; i < LED_COUNT; i++) {
      if (i < litLEDs) {
        uint32_t currentColor = strip.getPixelColor(i);
        uint32_t dimmedColor = dimColor(color);
        strip.setPixelColor(i, currentColor ? strip.Color(0, 0, 0) : dimmedColor);
      } else {
        strip.setPixelColor(i, strip.Color(0, 0, 0));
      }
    }
  }
}

void randomBlink(int litLEDs) {
  unsigned long currentMillis = millis();

  if (currentMillis - lastBlinkTime > blinkInterval) {
    lastBlinkTime = currentMillis;
    for (int i = 0; i < LED_COUNT; i++) {
      if (i < litLEDs) {
        uint32_t randomColor = strip.Color(random(256), random(256), random(256));
        uint32_t dimmedColor = dimColor(randomColor);
        strip.setPixelColor(i, dimmedColor);
      } else {
        strip.setPixelColor(i, strip.Color(0, 0, 0));
      }
    }
  }
}

uint32_t dimColor(uint32_t color) {
  uint8_t r = (uint8_t)(color >> 16);
  uint8_t g = (uint8_t)(color >> 8);
  uint8_t b = (uint8_t)color;

  r = (r * MAX_BRIGHTNESS) / 255;
  g = (g * MAX_BRIGHTNESS) / 255;
  b = (b * MAX_BRIGHTNESS) / 255;

  return strip.Color(r, g, b);
}

Wire connections

This image has an empty alt attribute; its file name is IMG_0585-472x1024.png
Test the code and the flexsensor

soldering to the Gemma Mo

Final test

Fnal look

Discover more from Making Studio

Subscribe now to keep reading and get access to the full archive.

Continue reading