Help! Can't upload code to trinket. no blinking red led

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
XRAD
 
Posts: 754
Joined: Sat Nov 19, 2016 3:28 pm

Re: Help! Can't upload code to trinket. no blinking red led

Post by XRAD »

OK Great! Cool. Now some simple neopixel ring code. MAKE sure you have the TM0 pins the same hardware hook-up as in your sketch. Watch the neopixel ring wiring. Positive to USB until you get a battery BLUE and RED lights up in series on the ring

upload the sketch. Then open up SERIAL MONITOR under the arduino IDE tools, and watch for the serial print line when u press the button.

One Note: this is for RGB, not RGBW neopixels

Code: Select all

//XRAD'S Frankencode Neopixel Servo Single Button press
//use this to activate a prop or some other cool things 

//Include some libraries so you can do things
#include <Adafruit_NeoPixel.h> 

#define BUTTON  1    // the pin that the momentary pushbutton is attached to. 3.3v to BUTTON, then back to PIN 1.  touch 3.3v to PIN 1 to activate
#define NEOPIXELPIN 4  // data pin OUT to the neopixels  
#define NUMPIXELS  20// ? how many do you have 
#define DELAYVAL1   80  //Delay to write the Adafruit_NeoPixel color 
#define BRIGHTNESS 100// 0 to 255

 

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEOPIXELPIN, NEO_GRB + NEO_KHZ800);


// Vegetables
int buttonState = 0;         // current state of the button
int lastButtonState = 0;
int pos;


void setup() {

  Serial.begin(9600);  // initialize serial communication
  pinMode(BUTTON, INPUT_PULLDOWN); //So I can use +3.3v to button then to BUTTON pin, built into chip
  pinMode(NEOPIXELPIN, OUTPUT);// initialize output
  pixels.begin();   //  initialize the NeoPixel library.
  pixels.show();   //clear pixels
  pixels.setBrightness(BRIGHTNESS);
}

void loop() {
  // read the pushbutton input pin 
  buttonState = digitalRead(BUTTON);
  //compare the buttonState to its previous state
  //this code will run once when button pressed
  if (buttonState == HIGH) {   // button FIRST press
    delay (30); // Delay a little bit to avoid button bounce

    if (lastButtonState == 0) { 
      Serial.println("COLORWIPE");

      //neopixels light up in one direction
      for (int i = 0; i < NUMPIXELS; i++) {
        pixels.setPixelColor(i, pixels.Color(100, 0, 0)); // red
        pixels.show(); // send data to neopix
        delay(DELAYVAL1);
      } 
      
      lastButtonState = 1;
    }
 //this code will run once when button pressed again!
    else if (lastButtonState == 1) { 
      Serial.println("COLORWIPE REVERSE");

      //neopixels light up in opposite direction
      for (int i = NUMPIXELS; i > -1; i--) {  //in reverse!!
        pixels.setPixelColor(i, pixels.Color(0, 0, 100)); //blue
        pixels.show();
        delay(DELAYVAL1); 
      }
      lastButtonState = 0;
    }
  }
}

User avatar
adafruit_support_carter
 
Posts: 29209
Joined: Tue Nov 29, 2016 2:45 pm

Re: Help! Can't upload code to trinket. no blinking red led

Post by adafruit_support_carter »

Sorry it was so problematic getting the board to show up. Not sure why all that was necessary. But it's there now and seems to be working, so all good. If it stops showing up or not taking programs again, let us know.

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

Return to “Trinket ATTiny, Trinket M0”