Arduino Vibrator Virtual Mistress

Selfbondage software and other kinky developments

Moderators: Riddle, Shannon SteelSlave

Post Reply
Tintin119
*
Posts: 6
Joined: 02 Jan 2013, 23:32

Arduino Vibrator Virtual Mistress

Post by Tintin119 »

This is my first piece of software for Arduino so bear with me in case its still buggy. Some of this is still in progress and I dont have everything designed yet but the prototpe is looking good. Please comment so I know if im heading in the right direction.

This is designed for males due to the nature of being able to clearly detect cum although feel free to make alterations to it.

The idea: I can use an Arduino as a teasing device by using a cum detector in order to force the user to cum at a certain time.

This program works by using an arduino to control a vibrator by just fading in and out (future versions may include more complex waves). There are 3 switches that are needed to get this to work (actually only 2 are really needed). The most important ones are the one that changes the maximum height of the wave (amplitude) and the other is a cum detector.

The amplitude starts at 0 and every time the user presses the amplitude button to raise the vibrator level, they are given a wait period and then a pass period. The led on the arduino blinks a number of times which is equal to the amplitude in order to indicate the beginning of the wait period. The wait period is designed such that the user has to wait for some time after increasing the strength before he can cum. Then he is given a pass period in which he is allowed to cum (indicated by the built in led light staying solid). If he cums anytime outside of the pass period he is punished by the vibrator being turned on to the max amount for a set duration called the failTime (this will be very punishing especially if the vibrator is powerful :whip: ). There is also a reset button that will set the amplitude to 0 but it cannot be used to escape the wait, pass, or fail period. In future examples the reset button might be omitted but i was thinking it would be useful if you reached a point of numbness.

Below is my code so far. These pin values are set by default to work with my arduino uno and your experience might depend on the board.

I have not thoroughly tested examples for the circuits used for the buttons and motor, but that will come should I see demand for it.

Note that the comments are somewhat ambiguous because I was working in a public area so i had to be discrete.

Code: Select all

/*
MotorLoopThingy

Inputs:
User connects a motor to the motorPin
User connects a button to the amplitudePin
User connects another button to reset pin
user connects detctor to detector pin
Built in led is already connected to led pin

Function:
The motor fades in and out and the amplitude of the motor is defined by the amplitude value
If the user would like to increase the amplitude, the user will press the amplitude button for at least the length of time of the delay then let go
This causes to motor to be fixed on for the waitTime and the passTime then the motor will start to fade again
If the user wants to pass, he must first press the amplitude button then wait for the waitTime to finish
The light will blink at the beginning of the waitTime and stay solid throughout the passTime
If the user finishes outside the passTime the motor will automatically ramp to a maximum for the failTime and led will stay solid during this time
The reset button can only be used if the detector circuit is not complete
The reset button will set the amplitude to 0
If the user either passes or fails, the amplitude will be set to 0
*/

//Time is in milliseconds (1/1000 of a second)
int failTime = 20000; //Time that motor remains at maximum if user fails
int delayTime = 80; //Time in between each fade cycle 
int waitTime = 10000; //Time needed to wait before user can pass
int passTime = 10000; //Time user gets in order to pass

//Pins for buttons and output devices (uses 13 as the led user indicator). Make sure that the motor is on a pwm pin for best functionality
//DO NOT DIRECTLY CONNECT MOTOR TO OUTPUT PINS, USE A MOTOR CONTROLLER
int amplitudePin = 7, detectorPin = 8, resetPin = 2, motorPin = 3, ledPin = 13;
int amplitude = 0, function = 0, change = 1, motor = 0; //Initialization settings *DO NOT CHANGE UNLESS YOU UNDERSTAND THE CODE*
int maxFunction = 25, maxAmplitude = 10; //Product of these should be less than 255

void setup()
{
  pinMode(amplitudePin, INPUT);
  pinMode(detectorPin, INPUT);
  pinMode(resetPin, INPUT);
  pinMode(motorPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}
void loop()
{
  //Detector gets set off (aka fail) and program not set to be turned off (amplitude = 0)
  if ((digitalRead(detectorPin) == HIGH) && (amplitude != 0))
  {
    digitalWrite(ledPin, HIGH); //Solid light to tell user failed
    motor = 255;
    analogWrite(motorPin, motor);
    delay (failTime);
    amplitude = 0; //Amplitude resets
    digitalWrite(ledPin, LOW);
  }

  //User changes amplitude
  if (digitalRead(amplitudePin) == HIGH)
  {
    amplitude += 1;
    if (amplitude >= maxAmplitude) //If amplitude is greater than maximum, it will reset amplitude to 0
    {
      amplitude = 0;
    }
    function = maxFunction; //during waitTime and passTime the motor will be constant at the maximum given the increased amplitude
    motor = function * amplitude;
    analogWrite(motorPin, motor);
    while (digitalRead(amplitudePin) == HIGH) //Waits until user unpresses button
    {
      delay(5);
    }
    for (int i = 1; i <= amplitude; i++) //Blinks a number of times equal to current amplitude. Also indicates beginning of waitTime
    {
      digitalWrite(ledPin, HIGH);
      delay(50);
      digitalWrite(ledPin, LOW);
      delay(50);
    }
    delay (waitTime); //Delay for waiting period
    if (digitalRead(detectorPin) == HIGH)//If user executes too early it will go to detector set off
    {}
    else //In case user waits for all of waitTime
    {
      digitalWrite(ledPin, HIGH); //Beginning of exit period
      delay(passTime);
      digitalWrite(ledPin, LOW); //End of exit period
      if (digitalRead(detectorPin) == HIGH) //If user finishes during exit period amplitude resets
      {
        amplitude = 0;
      }
    }
  }

  //Reset: Amplitude resets but cannot be used to escape if detector set off 
  if (digitalRead(resetPin) == HIGH && digitalRead(detectorPin) == LOW)
  {
    amplitude = 0;
    while (digitalRead(resetPin) == HIGH)
    {
      delay(10);
    }
  }

  //Fade Motor
  if (function >= 1 && function <= 24) //Changes function value only if function is between both endpoints
  {
    function += change;
  }
  if (function <= 0 || function >= 25) //Makes function fade both up and down
  {
    change = -change;
  }
  motor = function * amplitude;
  analogWrite(motorPin, motor);
  delay(delayTime);
}
Post Reply