Need help with Arduino Micro and Bluefruit project.

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
F3ckLand
 
Posts: 8
Joined: Mon Jul 21, 2014 10:29 am

Need help with Arduino Micro and Bluefruit project.

Post by F3ckLand »

Im following step by step the Make a Guggenhat Project.
So I'm at the Dry Run Stage and have come to a bump in the road. First off Soldering is done, got the libraries downloaded and put it the proper folders.
When I powered the micro from the start the Blue light on the bottom of the board lights up and so does the RX light. Not sure if that means anything???
Then I had trouble getting the Micro to be a visible com port when choosing Tools>Serial Port>Usb
I read online that the serial port on the micro is virtual and if need you can hold the rest button on the micro making the port visible and then to hold it until uploading appears, then release and the sketch will upload RX light blinks . It does seem to work the upload finishes and says done uploading.
Then the RX light goes out for a few seconds and then comes on solid again and the com port disappears.
According to the steps in the Project Guide I should be seeing a blinking green light and then a faster blinking green light. No such luck.
Any help would be welcomed. Im new to Arduino but have worked with several SCADA systems and have a decent base for this stuff.
TIA

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: Need help with Arduino Micro and Bluefruit project.

Post by Franklin97355 »

Could you post clear pictures of your board, any soldering you did and the connections to it?
Could you post your code and a description or drawing of your connections between it all? Please use the code button "</>" in the button bar when posting code to the forums.
Rather than requiring a physical press of the reset button before an upload, the Micro is designed in a way that allows it to be reset by software running on a connected computer. The reset is triggered when the Micro's virtual (CDC) serial / COM port is opened at 1200 baud and then closed. When this happens, the processor will reset, breaking the USB connection to the computer (meaning that the virtual serial / COM port will disappear). After the processor resets, the bootloader starts, remaining active for about 8 seconds. The bootloader can also be initiated by pressing the reset button on the Micro. Note that when the board first powers up, it will jump straight to the user sketch, if present, rather than initiating the bootloader.
Because of the way the Micro handles reset it's best to let the Arduino software try to initiate the reset before uploading, especially if you are in the habit of pressing the reset button before uploading on other boards. If the software can't reset the board you can always start the bootloader by pressing the reset button on the board.
Also don't forget to install the drivers http://arduino.cc/en/Guide/Windows#toc4

User avatar
F3ckLand
 
Posts: 8
Joined: Mon Jul 21, 2014 10:29 am

Re: Need help with Arduino Micro and Bluefruit project.

Post by F3ckLand »

Code: Select all

/*--------------------------------------------------------------------------
  GUGGENHAT: a Bluefruit LE-enabled wearable NeoPixel marquee.
 
  Requires:
  - Arduino Micro or Leonardo microcontroller board.  An Arduino Uno will
    NOT work -- Bluetooth plus the large NeoPixel array requires the extra
    512 bytes available on the Micro/Leonardo boards.
  - Adafruit Bluefruit LE nRF8001 breakout: http://www.adafruit.com/products/1697
  - 4 Meters 60 NeoPixel LED strip: http://www.adafruit.com/product/1461
  - 3xAA alkaline cells, 4xAA NiMH or a beefy (e.g. 1200 mAh) LiPo battery.
  - Late-model Android or iOS phone or tablet running nRF UART or
    Bluefruit LE Connect app.
  - BLE_UART, NeoPixel, NeoMatrix and GFX libraries for Arduino.
 
  Written by Phil Burgess / Paint Your Dragon for Adafruit Industries.
  MIT license.  All text above must be included in any redistribution.
  --------------------------------------------------------------------------*/
 
#include <SPI.h>
#include <Adafruit_BLE_UART.h>
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_GFX.h>
 
// NEOPIXEL STUFF ----------------------------------------------------------
 
// 4 meters of NeoPixel strip is coiled around a top hat; the result is
// not a perfect grid.  My large-ish 61cm circumference hat accommodates
// 37 pixels around...a 240 pixel reel isn't quite enough for 7 rows all
// around, so there's 7 rows at the front, 6 at the back; a smaller hat
// will fare better.
#define NEO_PIN     6 // Arduino pin to NeoPixel data input
#define NEO_WIDTH  37 // Hat circumference in pixels
#define NEO_HEIGHT  7 // Number of pixel rows (round up if not equal)
#define NEO_OFFSET  (((NEO_WIDTH * NEO_HEIGHT) - 240) / 2)
 
// Pixel strip must be coiled counterclockwise, top to bottom, due to
// custom remap function (not a regular grid).
Adafruit_NeoMatrix matrix(NEO_WIDTH, NEO_HEIGHT, NEO_PIN,
  NEO_MATRIX_TOP  + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
  NEO_GRB         + NEO_KHZ800);
 
char          msg[21]       = {0};            // BLE 20 char limit + NUL
uint8_t       msgLen        = 0;              // Empty message
int           msgX          = matrix.width(); // Start off right edge
unsigned long prevFrameTime = 0L;             // For animation timing
#define FPS 20                                // Scrolling speed
 
// BLUEFRUIT LE STUFF-------------------------------------------------------
 
// CLK, MISO, MOSI connect to hardware SPI.  Other pins are configrable:
#define ADAFRUITBLE_REQ 10
#define ADAFRUITBLE_RST  9
#define ADAFRUITBLE_RDY  2 // Must be an interrupt pin
 
Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(
  ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);
aci_evt_opcode_t  prevState  = ACI_EVT_DISCONNECTED;
 
// STATUS LED STUFF --------------------------------------------------------
 
// The Arduino's onboard LED indicates BTLE status.  Fast flash = waiting
// for connection, slow flash = connected, off = disconnected.
#define LED 13                   // Onboard LED (not NeoPixel) pin
int           LEDperiod   = 0;   // Time (milliseconds) between LED toggles
boolean       LEDstate    = LOW; // LED flashing state HIGH/LOW
unsigned long prevLEDtime = 0L;  // For LED timing
 
// UTILITY FUNCTIONS -------------------------------------------------------
 
// Because the NeoPixel strip is coiled and not a uniform grid, a special
// remapping function is used for the NeoMatrix library.  Given an X and Y
// grid position, this returns the corresponding strip pixel number.
// Any off-strip pixels are automatically clipped by the NeoPixel library.
uint16_t remapXY(uint16_t x, uint16_t y) {
  return y * NEO_WIDTH + x - NEO_OFFSET;
}
 
// Given hexadecimal character [0-9,a-f], return decimal value (0 if invalid)
uint8_t unhex(char c) {
  return ((c >= '0') && (c <= '9')) ?      c - '0' :
         ((c >= 'a') && (c <= 'f')) ? 10 + c - 'a' :
         ((c >= 'A') && (c <= 'F')) ? 10 + c - 'A' : 0;
}
 
// Read from BTLE into buffer, up to maxlen chars (remainder discarded).
// Does NOT append trailing NUL.  Returns number of bytes stored.
uint8_t readStr(char dest[], uint8_t maxlen) {
  int     c;
  uint8_t len = 0;
  while((c = BTLEserial.read()) >= 0) {
    if(len < maxlen) dest[len++] = c;
  }
  return len;
}
 
// MEAT, POTATOES ----------------------------------------------------------
 
void setup() {
  matrix.begin();
  matrix.setRemapFunction(remapXY);
  matrix.setTextWrap(false);   // Allow scrolling off left
  matrix.setTextColor(0xF800); // Red by default
  matrix.setBrightness(31);    // Batteries have limited sauce
 
  BTLEserial.begin();
 
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
}
 
void loop() {
  unsigned long t = millis(); // Current elapsed time, milliseconds.
  // millis() comparisons are used rather than delay() so that animation
  // speed is consistent regardless of message length & other factors.
 
  BTLEserial.pollACI(); // Handle BTLE operations
  aci_evt_opcode_t state = BTLEserial.getState();
 
  if(state != prevState) { // BTLE state change?
    switch(state) {        // Change LED flashing to show state
     case ACI_EVT_DEVICE_STARTED: LEDperiod = 1000L / 10; break;
     case ACI_EVT_CONNECTED:      LEDperiod = 1000L / 2;  break;
     case ACI_EVT_DISCONNECTED:   LEDperiod = 0L;         break;
    }
    prevState   = state;
    prevLEDtime = t;
    LEDstate    = LOW; // Any state change resets LED
    digitalWrite(LED, LEDstate);
  }
 
  if(LEDperiod && ((t - prevLEDtime) >= LEDperiod)) { // Handle LED flash
    prevLEDtime = t;
    LEDstate    = !LEDstate;
    digitalWrite(LED, LEDstate);
  }
 
  // If connected, check for input from BTLE...
  if((state == ACI_EVT_CONNECTED) && BTLEserial.available()) {
    if(BTLEserial.peek() == '#') { // Color commands start with '#'
      char color[7];
      switch(readStr(color, sizeof(color))) {
       case 4:                  // #RGB    4/4/4 RGB
        matrix.setTextColor(matrix.Color(
          unhex(color[1]) * 17, // Expand to 8/8/8
          unhex(color[2]) * 17,
          unhex(color[3]) * 17));
        break;
       case 5:                  // #XXXX   5/6/5 RGB
        matrix.setTextColor(
          (unhex(color[1]) << 12) +
          (unhex(color[2]) <<  8) +
          (unhex(color[3]) <<  4) +
           unhex(color[4]));
        break;
       case 7:                  // #RRGGBB 8/8/8 RGB
        matrix.setTextColor(matrix.Color(
          (unhex(color[1]) << 4) + unhex(color[2]),
          (unhex(color[3]) << 4) + unhex(color[4]),
          (unhex(color[5]) << 4) + unhex(color[6])));
        break;
      }
    } else { // Not color, must be message string
      msgLen      = readStr(msg, sizeof(msg)-1);
      msg[msgLen] = 0;
      msgX        = matrix.width(); // Reset scrolling
    }
  }
 
  if((t - prevFrameTime) >= (1000L / FPS)) { // Handle scrolling
    matrix.fillScreen(0);
    matrix.setCursor(msgX, 0);
    matrix.print(msg);
    if(--msgX < (msgLen * -6)) msgX = matrix.width(); // We must repeat!
    matrix.show();
    prevFrameTime = t;
  }
}
Last edited by Franklin97355 on Mon Aug 25, 2014 11:54 pm, edited 1 time in total.
Reason: Added right square bracket on [/code] tag

User avatar
F3ckLand
 
Posts: 8
Joined: Mon Jul 21, 2014 10:29 am

Re: Need help with Arduino Micro and Bluefruit project.

Post by F3ckLand »

Hope this helps
Image
Image
Image
Image

User avatar
F3ckLand
 
Posts: 8
Joined: Mon Jul 21, 2014 10:29 am

Re: Need help with Arduino Micro and Bluefruit project.

Post by F3ckLand »

This is what i followed
Image

User avatar
F3ckLand
 
Posts: 8
Joined: Mon Jul 21, 2014 10:29 am

Re: Need help with Arduino Micro and Bluefruit project.

Post by F3ckLand »

This project has been on the back burner but I have made progress. Sorted out the wiring and got the leds working, got the bluetooth working good, I cant sent it words and they are displayed, I can change the color, all is well. My coiled grid is slightly different than the example and therefore my words are all crooked (Sorta looks like italics) The top row displays sooner that the bottom. So there is a place in the code to adjust this exact thing #define NEO_WIDTH # (also explanied in the comments)

Im new to the programming side of things, not sure exactly what value to change because it seems when i change the number right after #define NEO_WIDTH (currently 6) it doesnt affect the pattern on my message board.

If someone would like to read through this post and the previous posts the whole story is layed out for you, let me know what they think that would be super helpfull.
TIA


User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need help with Arduino Micro and Bluefruit project.

Post by adafruit_support_mike »

NEO_WIDTH is the circumfrence of your loop in pixels. NEO_HEIGHT is the number of times the coil loops back on itself.

To find the width, locate the first pixel in the strip, then go up to the one directly above it. Call that pixel-0. Work your way back along the strip toward the first pixel, numbering the pixels as you go. The final number (for the first pixel in the strip) will the NEO_WIDTH.

When the code wants to light the first pixel of the second row, it will skip ahead to pixel NEO_WIDTH+1, which should be the one directly above the first pixel in the strip.

User avatar
F3ckLand
 
Posts: 8
Joined: Mon Jul 21, 2014 10:29 am

Re: Need help with Arduino Micro and Bluefruit project.

Post by F3ckLand »

thanks, so i have adjusted the Neo width several times, the issue im having is that it seem that its not accepting the change or its just not enacting the change. The same crooked letters occur no matter what i put in for a neo width

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need help with Arduino Micro and Bluefruit project.

Post by adafruit_support_mike »

Just to refresh, post the code you're using now please (between CODE tags).

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

Return to “Arduino”