Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel Trinkey Analog JST pin #369

Merged
merged 1 commit into from
Sep 18, 2024
Merged

Pixel Trinkey Analog JST pin #369

merged 1 commit into from
Sep 18, 2024

Conversation

mikeysklar
Copy link

Adding analog support to the 3-pin JST A6.

Based on an Adafruit forum issue and help from user bullimore.

Tested with Trinkey Pixel and high density dotstar strip with the following code. Dims and brightnes with potentiometer adjustment.

#include <Adafruit_DotStar.h>

#define NUMPIXELS 72
#define ANALOG_PIN A6 

Adafruit_DotStar dotstrip(NUMPIXELS, PIN_DATA, PIN_CLOCK, DOTSTAR_BRG);

void setup() {
  Serial.begin(115200);
  dotstrip.begin();
  dotstrip.setBrightness(10);  // Initial brightness
  dotstrip.show();
}

void loop() {
  // Read the analog value 
  int sensorValue = analogRead(ANALOG_PIN);

  // Map the analog value (0-1023) to brightness (0-255)
  int brightness = map(sensorValue, 0, 1023, 0, 255);

  // Set the brightness of the LED strip
  dotstrip.setBrightness(brightness);

  // Optionally, print the sensor value and brightness for debugging
  Serial.print("Sensor Value: ");
  Serial.print(sensorValue);
  Serial.print(" Brightness: ");
  Serial.println(brightness);

  // Set all pixels to white with the adjusted brightness
  for (int i = 0; i < dotstrip.numPixels(); i++) {
    dotstrip.setPixelColor(i, dotstrip.Color(255, 255, 255));  // White color
  }
  dotstrip.show();  // Update the strip to show the new brightness
  delay(100);  // Short delay to make brightness changes smoother
}

Adding analog support to the 3-pin JST A6.
@mikeysklar
Copy link
Author

@ladyada please review.

@ladyada ladyada merged commit bb55281 into adafruit:master Sep 18, 2024
12 checks passed
@ladyada
Copy link
Member

ladyada commented Sep 18, 2024

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants