Wearable reminder device

I'm attempting to build a wearable device that will be turned on and off with a button/break in the circuit, vibrate indefinitely at the end of a timer, say 3 minutes (although eventually this would be defined by analog user input) and a button press during the vibration restarts the cycle.

Unfortunately, I have never used arduino before. I know what I want to do, but lack the knowledge to implement it. Any help from the forum community would be well appreciated!

This is for a collaborative project between industrial design majors and occupational therapy majors, and could potentially be given to a client to help with their challenges.

So far, I have gotten a cell phone motor to vibrate on a set interval, with this code:

const int motorPin = 3;

void setup()
{
pinMode(motorPin, OUTPUT);
}

void loop()
{
digitalWrite(motorPin, HIGH);
delay(1000);
digitalWrite(motorPin, LOW);
delay(59000);
}

I'm somewhat lost after this though, considering using the "timer" or "delay" commands, but I just do not know enough on my own.

Thanks for any help!

I'm not quite sure I completely understand what you're asking. But from what I see, if you're trying to make a break in the circuit, I guess you could just add a switch between the battery terminal and the arduino you use.

I don't know if you can add a delay in the setup though? Otherwise you might be able to do something like:

const int motorPin = 3;

void setup()
{
  pinMode(motorPin, OUTPUT);
  digitalWrite(motorPin, LOW);
  delay(180000);
}

void loop()
{
  digitalWrite(motorPin, HIGH);
}

If it helps I recommend going through some of these:
http://oomlout.com/a/products/ardx/

There very easy to do, and fairly easy to understand how things work and what you do to use what. For example the delay functions and motors.

I probably wasn't very clear, so I'll try and outline my goal a bit better:

The device needs to vibrate on a timer that can be adjusted by the user, and each vibration needs to be stopped with a button press that would signal the start of the next cycle.

The user would adjust the timer by turning a dial to the desired time amount (1 to 30 min)

The whole device would be turned on by a clip/button/break in the circuit that is activated by clipping the device to a belt or pocket or bracelet band - this part I have a fairly good idea of how itll work.

I'm thinking I could modify the code from post #6 here:
http://arduinoexperiments.tumblr.com/

In his scenario, once the light turns on, what happens if the button is pressed again? For this to work for my application, a button press once the motor ( in this case the led) is on would need to stop the current vibration/light and restart the timer.

Thanks for the reply!

If you are allowing the user to turn a knob to set the time, you will need to measure its position and also display its current position to the user.

You will need an LCD display, or 8 segment displays etc, and look into using a rotary encoder for the knob. you can specify the min and max values, 0-30, and then multiply its position by 60,000 to give you the minutes in milliseconds, and store it in a variable for comparison.

Rather than using a delay(xxxxx) I would be inclined to take a reading from millis() which is how many milliseconds have passed since the sketch has been running and then using an if condition to see if the time has passed.

if(millis>duration)
{
//Turn on the vibration motor
}

You will also need a section of code which detects each change of the rotary encoder, and on each change it resets the millis back to zero.

if you are incorporating a start button etc, then encase the lot in a for loop, with the button press increasing an integer value which triggers the condition of the loop

There are some easy to use examples on the arduino IDE which will show you how to use an LCD sreen.

Are you sure I need an lcd? I was thinking I'd use a potentiometer attached to an indicator knob, so that the position is clear.

I'm an industrial design student, so the final model will be 3d printed and finished as necessary, and was definitely going for an analog interface on the device.

No, he's not saying you need an LCD, just that some kind of output device is probably a good thing. Sounds like you may not want one, though, and you can get by that way, sure.

A knob could certainly do the trick, but is hard to make such that it's both easy to use and hard to knock to a wrong setting. But if you went with up/down buttons and an output device, that part could be easier, maybe. But it's your design, certainly.

As for the coding part, you have to get REAL specific about what you want to get people to do it for you, which is along the lines of what you seem to be really asking. :slight_smile:

For a true analog knob, all you need is to attach it to a potentiometer connected to an analog input. That's described perfectly here:

Another idea for a simple feedback would be to dim/brighten a single LED based on that same potentiometer input. You would attach the LED to a PWM output on the Arduino, like so:

Even if you don't use this in the final device, it might be handy for your own use during prototyping and debugging to add this.

--Donnie

So I’ve gotten this far:

unsigned long starttimer;
unsigned long timerbegin;
unsigned long elapsedtime;
int potval;
int counterdays;
int button;
int buttonstate;
int buttoncounter;
int counter;
void setup(){
  Serial.begin(9600);
pinMode(11, OUTPUT);
pinMode(8, INPUT);
Serial.begin(9600);
}
void loop(){
          potval = analogRead(0);
          counterdays = map(potval, 0, 1023, 1, 5);
 button = analogRead(1);
 buttonstate= map(button,0,1023,10,0);
if (buttonstate >=5){
buttoncounter ++;
}
if (buttoncounter >= 1){
timerbegin++;
delay(1000);
 Serial.println(timerbegin);
 if (timerbegin>= counterdays ){
   digitalWrite(11, HIGH);
 }

Currently, this turns an led on after setting the delay with a potentiometer and pressing a button. Once the led is on, I have to reset the arduino micro board, and press the original button again for the next cycle.

Is there any way that the original button can be pressed to turn the light off and start the next cycle simultaneously?

After I have this working exactly how I want, I’ll replace the led with a motor.

Thanks!

djb_rh:
--Donnie

Any chance you have any more suggestions in regards to my latest post? Sorry to double post, but I'm on a tight deadline with this project.

All I need at this point is for a second press of the button that is pushed to start the count cycle to turn the vibration off and start the next cycle. Does anyone have a suggestion on how to make that happen? Code as is now is found above.