Go Down

Topic: GUI for interfacing with data collection box help (Read 174 times) previous topic - next topic

kcpilotguy

To start, I have a device that looks like this:





and I just got everything working thanks to the kind folks in this forum...what it will do is just record values form a potentiometer as someone watches a video clip.  For example if it is a clip of a car driving across the street and you are a pedestrian, if you feel safe to cross the value of the dial will be at "0" and as you feel less safe, you will increase the dial until you no longer want to cross the street at "1023" on the dial. 

This is just a simplified example of what we're trying to do.  What I would like to get some guidance on is how to make a GUI that is an instruction guide that is a window with a video on the right and maybe a counter or plotter on the left that lets people begin by "testing" the dial a bit.  They would push the button on the device to start testing, then press again to end, and on third press the video would start and data would be recording.  At this point the counter/plotter could disappear or stay...whatever is easier honestly.

I imagine it's a relatively simple python thing, but as I am a complete novice at this stuff any guidance would be appreciated. 

Also here is the code for the device:

Code: [Select]
//Version 1

unsigned long prevMillis;

int buttonPushCounter = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor

const byte sensorPin = A0;
const byte buttonPin = 2;
const byte ledPin = 13;

byte buttonState = 0;
byte lastButtonState = 0;

bool start = false;

//**************************************************************************************************************
void setup()
{
  Serial.begin(9600);
  Serial.println("CLEARDATA"); //clears up any data left from previous projects
  Serial.println("LABEL,Time,Timer,Sensor Value"); //always write LABEL, so excel knows the next things will be the names of the columns
  Serial.println("RESETTIMER"); //resets timer to 0

  pinMode(ledPin, OUTPUT);

  pinMode(buttonPin, INPUT);
  lastButtonState = digitalRead(buttonPin);

} //END of setup()

//**************************************************************************************************************
void loop()
{
  //****************************
  //check the switch every 50ms
  if (millis() - prevMillis >= 50)
  {
    //restart timer
    prevMillis = millis();

    checkSwitch();
  }

  //****************************
  if ( start == true)
  {
    sensorValue = analogRead(sensorPin);
    //writes the time in the first column A and the time since the measurements started in column B
    Serial.println(String("") + "DATA,TIME,TIMER," + sensorValue);
  }
  //****************************

} //END of loop()


//**************************************************************************************************************
void checkSwitch()
{
  buttonState = digitalRead(buttonPin);

  //Compare the buttonState to its previous state
  if (buttonState != lastButtonState)
  {
    //update to the new state
    lastButtonState = buttonState;

    //if button state is pushed
    if (buttonState == HIGH)
    {
      buttonPushCounter++;
      digitalWrite(ledPin, HIGH);

      //enable printing
      start = !start;
    }
  }
 
} //END of checkSwitch()

Robin2

This is not the Forum to get advice about writing a Python program. This simple Python - Arduino demo should help with communication between your Arduino and Python.

I wrote this Python GUI demo a long time ago and to be honest I have forgotten what is in it. It may give you some ideas but I won't be able to give any follow-up support.

Nowadays I create my GUIs with a web server and HTML and CSS. That means they can be viewed on anything with a browser. I use the Python Bottle web framework for my server.

...R


Two or three hours spent thinking and reading documentation solves most programming problems.

kcpilotguy

Appreciate the feedback. Will look at this stuff and go from there.


Go Up