NeoKey_1x4 with ESP32 QT PY in Arduino IDE issues RESOLVED!!!!!

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mariobro_3
 
Posts: 7
Joined: Wed Jan 04, 2023 3:51 pm

NeoKey_1x4 with ESP32 QT PY in Arduino IDE issues RESOLVED!!!!!

Post by mariobro_3 »

If you want to use an ESP32-S2 QT PY with the neokey 1x4 in Arduino IDE and NOT circutpython...
then here you go:
The basic examples DO NOT WORK!!! There is no specifier for this, the only reason I found this is because of the rp2040 having a similar issue. I did exactly what was posted in github comments, and even that did not work.
SO here you go, have fun, your welcome. Somene who is a better dev than i should make this easier for everyone and specify somewhere on github or adafruit's website.

Code: Select all

#include "Adafruit_NeoKey_1x4.h"
#include "seesaw_neopixel.h"

Adafruit_NeoKey_1x4 neokey (NEOKEY_1X4_ADDR, &Wire1);

void setup() {

  neokey.begin(NEOKEY_1X4_ADDR);
  Serial.begin(115200);
  delay(3000); 
  Serial.println("NeoKey started!");

  // Pulse all the LEDs on to show we're working
  for (uint16_t i=0; i<neokey.pixels.numPixels(); i++) {
    neokey.pixels.setPixelColor(i, 0x808080); // make each LED white
    neokey.pixels.show();
    delay(50);
  }
  for (uint16_t i=0; i<neokey.pixels.numPixels(); i++) {
    neokey.pixels.setPixelColor(i, 0x000000);
    neokey.pixels.show();
    delay(50);
  }
}

void loop() {
  uint8_t buttons = neokey.read();

  // Check each button, if pressed, light the matching neopixel
  
  if (buttons & (1<<0)) {
    Serial.println("Button A");
    neokey.pixels.setPixelColor(0, 0xFF0000); // red
  } else {
    neokey.pixels.setPixelColor(0, 0);
  }

  if (buttons & (1<<1)) {
    Serial.println("Button B");
    neokey.pixels.setPixelColor(1, 0xFFFF00); // yellow
  } else {
    neokey.pixels.setPixelColor(1, 0);
  }
  
  if (buttons & (1<<2)) {
    Serial.println("Button C");
    neokey.pixels.setPixelColor(2, 0x00FF00); // green
  } else {
    neokey.pixels.setPixelColor(2, 0);
  }

  if (buttons & (1<<3)) {
    Serial.println("Button D");
    neokey.pixels.setPixelColor(3, 0x00FFFF); // blue
  } else {
    neokey.pixels.setPixelColor(3, 0);
  }  

  neokey.pixels.show();
  
  delay(1000);    // don't print too fast
}



/******************************************/

// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return seesaw_NeoPixel::Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return seesaw_NeoPixel::Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return seesaw_NeoPixel::Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  return 0;
}

User avatar
mariobro_3
 
Posts: 7
Joined: Wed Jan 04, 2023 3:51 pm

Re: NeoKey_1x4 with ESP32 QT PY in Arduino IDE issues RESOLVED!!!!!

Post by mariobro_3 »

The specific line neokey.begin(NEOKEY_1X4_ADDR);
is neokey.begin(0x30); in the example. Don't know why that didn't work as that's the address...

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”