Hey, I'm attempting to make the Buzzing Mindfulness Bracelet but I'm having an issue. I have wired it all up as it shows in the tutorial, I've got the code loaded on and when I turn my Gemma on the Haptic Motor buzzes about 23 times while the Red LED Blinks at the same time. After that nothing, the Green LED in on but the Haptic Motor Doesn't buzz. Im trying to use the code supplied and not changing anything. This was happening when I set up the wiring 'dry' just using Alligator clips, but after soldering it made no difference.
I have attached a photo of my Gemma, hope someone can help!
Buzzing Bracelet
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- cahilljallan
- Posts: 7
- Joined: Mon May 02, 2016 7:10 pm
Buzzing Bracelet
- Attachments
-
- IMG_0190.jpg (616.59 KiB) Viewed 743 times
- adafruit_support_bill
- Posts: 88141
- Joined: Sat Feb 07, 2009 10:11 am
Re: Buzzing Bracelet
If you disconnect one wire of the motor, does the red led come on once per minute?After that nothing, the Green LED in on but the Haptic Motor Doesn't buzz.
- cahilljallan
- Posts: 7
- Joined: Mon May 02, 2016 7:10 pm
Re: Buzzing Bracelet
So after removing the Negative wire for the motor from the circuit I tried again under power from a Lipo battery and also from the USB Power source (laptop USB2)
When connected with the battery and turned on the Green LED is Bright, the Red LED comes on Dull for about 3 seconds then goes off, it does not then light up again, even after 60 seconds. (the Battery is Fully Charged)
When connected to the USB and turned on, the Green LED is Bright and Red LED Flashes brightly about 24 times then goes off and does not flash again.
Ive tried re adding the code, its simply copied and pasted from the Adafruit source and I'm not changing anything.
When connected with the battery and turned on the Green LED is Bright, the Red LED comes on Dull for about 3 seconds then goes off, it does not then light up again, even after 60 seconds. (the Battery is Fully Charged)
When connected to the USB and turned on, the Green LED is Bright and Red LED Flashes brightly about 24 times then goes off and does not flash again.
Ive tried re adding the code, its simply copied and pasted from the Adafruit source and I'm not changing anything.
Code: Select all
// Mindfulness Bracelet sketch for Adafruit/Arduino Gemma. Briefly runs
// vibrating motor (connected through transistor) at regular intervals.
// This code is not beginner-friendly, it does a lot of esoteric low-level
// hardware shenanigans in order to conserve battery power.
const uint32_t // These may be the only lines you need to edit...
onTime = 2 * 1000L, // Vibration motor run time, in milliseconds
interval = 60 * 1000L; // Time between reminders, in milliseconds
// It gets progressively geekier from here...
// Additional power savings can optionally be realized by disabling the
// power-on LED, either by desoldering or by cutting the trace from 3Vo
// on the component side of the board.
// This sketch spends nearly all its time in a low-power sleep state...
#include <avr/power.h>
#include <avr/sleep.h>
// The chip's 'watchdog timer' (WDT) is used to wake up the CPU when needed.
// WDT runs on its own 128 KHz clock source independent of main CPU clock.
// Uncalibrated -- it's "128 KHz-ish" -- thus not reliable for extended
// timekeeping. To compensate, immediately at startup the WDT is run for
// one maximum-duration cycle (about 8 seconds...ish) while keeping the CPU
// awake, the actual elapsed time is noted and used as a point of reference
// when calculating sleep times. Still quite sloppy -- the WDT only has a
// max resolution down to 16 ms -- this may drift up to 30 seconds per hour,
// but is an improvement over the 'raw' WDT clock and is adequate for this
// casual, non-medical, non-Mars-landing application. Alternatives would
// require keeping the CPU awake, draining the battery much quicker.
uint16_t maxSleepInterval; // Actual ms in '8-ish sec' WDT interval
volatile uint32_t sleepTime = 1; // Total milliseconds remaining in sleep
volatile uint16_t sleepInterval = 1; // ms to subtract in current WDT cycle
volatile uint8_t tablePos = 0; // Index into WDT configuration table
void setup() {
// Unused pins can be set to INPUT w/pullup -- most power-efficient state
pinMode(0, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
// LED shenanigans. Rather that setting pin 1 to an output and using
// digitalWrite() to turn the LED on or off, the internal pull-up resistor
// (about 10K) is enabled or disabled, dimly lighting the LED with much
// less current.
pinMode(1, INPUT); // LED off to start
// AVR peripherals that are NEVER used by the sketch are disabled to save
// tiny bits of power. Some have side-effects, don't do this willy-nilly.
// If using analogWrite() to for different motor levels, timer 0 and/or 1
// must be enabled -- for power efficiency they could be turned off in the
// ubersleep() function and re-enabled on wake.
power_adc_disable(); // Knocks out analogRead()
power_timer1_disable(); // May knock out analogWrite()
power_usi_disable(); // Knocks out TinyWire library
DIDR0 = _BV(AIN1D) | _BV(AIN0D); // Digital input disable on analog pins
// Timer 0 isn't disabled yet...it's needed for one thing first...
// The aforementioned watchdog timer calibration...
uint32_t t = millis(); // Save start time
noInterrupts(); // Timing-critical...
MCUSR &= ~_BV(WDRF); // Watchdog reset flag
WDTCR = _BV(WDCE) | _BV(WDE); // WDT change enable
WDTCR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); // 8192-ish ms interval
interrupts();
while(sleepTime); // Wait for WDT
maxSleepInterval = millis() - t; // Actual ms elapsed
maxSleepInterval += 64; // Egyptian constant
power_timer0_disable(); // Knocks out millis(), delay(), analogWrite()
}
const uint32_t offTime = interval - onTime; // Duration motor is off, ms
void loop() {
pinMode(1, INPUT_PULLUP); // LED on (using internal pullup)
ubersleep(onTime); // Delay while LED/motor on
pinMode(1, INPUT); // LED off
ubersleep(offTime); // Delay while off
}
// WDT timer operates only in specific intervals based on a prescaler.
// CPU wakes on each interval, prescaler is adjusted as needed to pick off
// the longest setting possible on each pass, until requested milliseconds
// have elapsed.
const uint8_t cfg[] PROGMEM = { // WDT config bits for different intervals
_BV(WDIE) | _BV(WDP3) | _BV(WDP0), // ~8192 ms
_BV(WDIE) | _BV(WDP3) , // ~4096 ms
_BV(WDIE) | _BV(WDP2) | _BV(WDP1) | _BV(WDP0), // ~2048 ms
_BV(WDIE) | _BV(WDP2) | _BV(WDP1) , // ~1024 ms
_BV(WDIE) | _BV(WDP2) | _BV(WDP0), // ~512 ms
_BV(WDIE) | _BV(WDP2) , // ~256 ms
_BV(WDIE) | _BV(WDP1) | _BV(WDP0), // ~128 ms
_BV(WDIE) | _BV(WDP1) , // ~64 ms
_BV(WDIE) | _BV(WDP0), // ~32 ms
_BV(WDIE) // ~16 ms
}; // Remember, WDT clock is uncalibrated, times are "ish"
void ubersleep(uint32_t ms) {
if(ms == 0) return;
tablePos = 0; // Reset WDT config stuff to
sleepInterval = maxSleepInterval; // longest interval to start
configWDT(ms); // Set up for requested time
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Deepest sleep mode
sleep_enable();
while(sleepTime && (tablePos < sizeof(cfg))) sleep_mode();
noInterrupts(); // WDT off (timing critical)...
MCUSR &= ~_BV(WDRF);
WDTCR = 0;
interrupts();
}
static void configWDT(uint32_t newTime) {
sleepTime = newTime; // Total sleep time remaining (ms)
// Find next longest WDT interval that fits within remaining time...
while(sleepInterval > newTime) {
sleepInterval /= 2; // Each is 1/2 previous
if(++tablePos >= sizeof(cfg)) return; // No shorter intervals
}
uint8_t bits = pgm_read_byte(&cfg[tablePos]); // WDT config bits for time
noInterrupts(); // Timing-critical...
MCUSR &= ~_BV(WDRF);
WDTCR = _BV(WDCE) | _BV(WDE); // WDT change enable
WDTCR = bits; // Interrupt + prescale
interrupts();
}
ISR(WDT_vect) { // Watchdog timeout interrupt
configWDT(sleepTime - sleepInterval); // Subtract, setup next cycle...
}
- adafruit_support_bill
- Posts: 88141
- Joined: Sat Feb 07, 2009 10:11 am
Re: Buzzing Bracelet
Make sure that those bare transistor & diode leads are not shorting out against anything. In the photo they are dangerously close to the metal reset switch body and the pin 0 pad.
- cahilljallan
- Posts: 7
- Joined: Mon May 02, 2016 7:10 pm
Re: Buzzing Bracelet
Yeah I couldn't get shrink wrap on them, just have to get some black tape. I have lifted it so they have at least 10/15mm clearance and is not shorting.
Before I soldered it all together I tried it with Alligator clips and It was having the same issue. This is my 2nd Gemma board for the first one had bootloader issues, so i think the hardware is okay, I'm just not sure what it could be and I'm running out of time because I'm using it as part of a University project.
Before I soldered it all together I tried it with Alligator clips and It was having the same issue. This is my 2nd Gemma board for the first one had bootloader issues, so i think the hardware is okay, I'm just not sure what it could be and I'm running out of time because I'm using it as part of a University project.
- cahilljallan
- Posts: 7
- Joined: Mon May 02, 2016 7:10 pm
Re: Buzzing Bracelet
ran some much more basic code, just to test, and it works great!
but I'm just not sure how long the battery will last without any power saving options.
but I'm just not sure how long the battery will last without any power saving options.
Code: Select all
const int motorPin = 1;
void setup()
{
pinMode(motorPin, OUTPUT);
}
void loop()
{
digitalWrite(motorPin, HIGH);
delay(2000);
digitalWrite(motorPin, LOW);
delay(59000);
}
- adafruit_support_bill
- Posts: 88141
- Joined: Sat Feb 07, 2009 10:11 am
Re: Buzzing Bracelet
That was going to be my next suggestion. Good to see that much is working OK. Not sure what is the issue with the power-saving trickery. I'll check with the author of the guide.ran some much more basic code, just to test, and it works great!
- adafruit_support_bill
- Posts: 88141
- Joined: Sat Feb 07, 2009 10:11 am
Re: Buzzing Bracelet
Actually, looking more closely at your circuit, it seems you have the transistor wired in reverse. Looking at the side with the lettering, the emitter is the pin on the left. That should go to GND.
- drumminhands
- Posts: 36
- Joined: Tue Jul 23, 2013 10:02 am
Re: Buzzing Bracelet
I had some 1N4007's sitting around instead of 1N4001. Is that going to be a problem?
- adafruit_support_bill
- Posts: 88141
- Joined: Sat Feb 07, 2009 10:11 am
Re: Buzzing Bracelet
Should not be a problem.
- snillevilla
- Posts: 3
- Joined: Fri May 12, 2017 11:36 am
Re: Buzzing Bracelet
Hi!
I had a similar problem with this tutorial. The motor was not buzzing with the original tutorial code, but worked perfectly with the 'simple' code.
Could it be that I, too, have soldered the transistor wrong? The image in the original tutorial seems to suggest that I have done it correctly, but I am unsure.
I had a similar problem with this tutorial. The motor was not buzzing with the original tutorial code, but worked perfectly with the 'simple' code.
Could it be that I, too, have soldered the transistor wrong? The image in the original tutorial seems to suggest that I have done it correctly, but I am unsure.
- Attachments
-
- elektronik_done_front.jpg (708.36 KiB) Viewed 565 times
- snillevilla
- Posts: 3
- Joined: Fri May 12, 2017 11:36 am
Re: Buzzing Bracelet
Update: I resoldered the transistor to the correct position, but the original code still does not work. The simple code works, and the motor buzzes a lot more forcefully after the change :)
I notice that the author uses an Arduino Gemma in the project, but both me and the thread starter use an Adafruit Gemma. Maybe code that works on Arduino version does not work on Adafruit?
I notice that the author uses an Arduino Gemma in the project, but both me and the thread starter use an Adafruit Gemma. Maybe code that works on Arduino version does not work on Adafruit?
- adafruit_support_bill
- Posts: 88141
- Joined: Sat Feb 07, 2009 10:11 am
Re: Buzzing Bracelet
Can you elaborate? Is there any noise or vibration at all from the motor?but the original code still does not work.
- snillevilla
- Posts: 3
- Joined: Fri May 12, 2017 11:36 am
Re: Buzzing Bracelet
Exactly the same as the thread starter described: when I switch the Gemma on, the red led blinks and the motor buzzes like crazy for a while and then nothing.
I tried various modifications of the code (not proficient in C, so it was more like 'let's change this and see what happens'), but could not get it to work.
I tried various modifications of the code (not proficient in C, so it was more like 'let's change this and see what happens'), but could not get it to work.
- vide
- Posts: 1
- Joined: Mon Oct 22, 2018 12:26 pm
Re: Buzzing Bracelet
Did anyone figure this out? I'm having the same problem. A simpler code works fine, but the original doesn't.
Please be positive and constructive with your questions and comments.