Tuesday, June 21, 2016

Semi-Automatic Data Collection

     Using an Arduino and a speaker, I have made a way to semi-automate the data collection process. What it does is emit a tone through a speaker then waits 35 seconds, this gives the counter enough time to collect data. The only thing the user has to do is hit the green button in the STX program to begin counting every time they hear a tone. They also have to change the preferences to 3 runs and the preset time to 10 seconds at the beginning. An LED can be also be used for the hearing impaired, and it will blink when the it is ready for the counting to start.
     This was the best solution I could think of. I could not find a way to fully automate it. There does not seem to be a way for the arduino software to communicate with the STX software. However finding a way to fully automate the process would be interesting.  

     I will leave the code in the comments, it goes into further detail of how to set up the circuit. I will also include a code that uses a button to move the motor and a variable resistor to change direction.  
     

3 comments:

  1. //Usage
    //This code is to be used with the Tel-X-ometer, ST360 and the STX software
    //In the STX software, set the preset time to 10 seconds and the
    //number of runs to 3. (If you wish to use other times, change the delays
    //in the code).
    //Everytime the speaker emits a tone hit the green start button
    //in the STX program. After 30 seconds the motor will move one
    //degree and emit another tone.

    //The Circuit
    // With the adafruit motor shield, connect a speaker to analog pin 1
    //and ground, for the hearing impaired an LED can also be connected
    //from A1 to ground.
    //Connect the motor from M3 to pin 4, and M4 to pins 5 and 6
    //Use a 9V to power the shield



    #define NOTE_C5 523
    #include

    AF_Stepper motor(20, 2);

    void setup() {
    Serial.begin(9600);
    motor.setSpeed(100);
    pinMode(16, OUTPUT);
    }




    void loop() {
    // put your main code here, to run repeatedly:
    tone(15, 523, 1000);
    delay(35000);
    motor.step(32, FORWARD, INTERLEAVE);
    delay(1000);
    }

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. //This code moves the arm one degree every push of the button
    // Turning the pot from one side to the other changes the direction

    //The button is connected to 5V and pin two and a 1K ohm
    //resisitor is connects pin two and the button to ground.
    //The pot is connected to 5V and ground and the middle wire is
    //connected to pin A0
    //The motor shield is given 9V from a battery

    #include

    AF_Stepper motor(20, 2);
    const int buttonPin = 2;
    int buttonState = 0;
    int potpin = 0;
    int val = 0;

    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    motor.setSpeed(100);
    }

    void loop(){
    buttonState = digitalRead(buttonPin);
    val = analogRead(potpin);
    Serial.println(val);
    switch (val){
    case 0:
    if (buttonState == HIGH){
    motor.step(32, BACKWARD,INTERLEAVE);
    delay(1000);
    break;
    }
    else{

    }
    case 1023:
    if (buttonState == HIGH){
    motor.step(32, FORWARD,INTERLEAVE);
    delay(1000);
    break;
    }
    else{
    }
    }
    }

    ReplyDelete