• Home
  • 2017
  • 2016
  • 2015
  • 2014
  • 2013
  • 2012
  • 2011

PDI Studio 5

Design to make a difference

Feed on
Posts
comments

The Code

Nov 29th, 2012 by shawr2

How it Works

The code starts by trying to connect to the Arduino in all the different locations it could be on a windows machine.  Once it finds the proper COM port it sets the baud rate to 9600 for the serial communication between python and the Arduino.

The GUI for python was made using the “easygui” module, available at this link: http://easygui.sourceforge.net/. This module allows the programmer to make a very simple graphical user interface consisting of message boxes, boxes with buttons, boxes with a list of choices, and boxes with fields to enter information. The programmer can also add pictures to some of the types of boxes, as well as titles. The standard msgbox can accommodate a message, a title, a picture, and and buttons by simply writing eg.msgbox(message = “message”, title = “title”, choices = [“A”, “B”, “C”], image = image.gif)

To add in the pictures that are shown when a player answers a question, one must place a .gif version of that image in the same folder as the .py program is in.

The gui is the only part of the program that is used as the player goes through the game. Button boxes are used for the questions, and message boxes are used for the correct or wrong answer screens, as well as the final screen.

Once the user clicks “Go!” the code will send a command to the Arduino in the form of a string.  The Arduino is constantly checking for a signal from python to be sent to it.  When it receives the signal it processes it and then picks the correct profile from the three choices for graphs 1, 2, or 3.  The signal is created by incrementing a variable ‘i’ to change the duty cycle of the PWM signal.  To switch the polarity of the signal to the track a high signal was sent to the relay, this allowed us to make the car travel forwards and backwards around the track using only one power circuit.

The Python Code

# Too Fast, Too Curious 
# Ben Clemence, Austin Pietrobono, Rosalie Isis Shaw
# PDI Studio V, Ron Eglash, Fall 2012

# The program is a GUI that will control a slot car track with an Arduino

# import GUI library
import easygui as eg

# import serial communication library for communication with the Arduino
import serial
import pygtk

# Possible COM ports that the Arduino could be connected to
ports=[‘COM1′,’COM2′,’COM4′,’COM5′,’COM6′,’COM7′,’COM8′,’COM9′,’COM10′,’COM11′,’COM12′,’COM13′,’COM14′,’COM15’]    
 
# try to find the Arduino  
for device in ports:  
    try:  
        print “Trying…”,device  
        arduino = serial.Serial(device, 9600)  
        break  
    except:  
        print “Failed to connect on”,device  

######################################Graph3###################################################
def graph3():
    eg.buttonbox(msg = “Watch it Happen!”, title = “Graph 3”, image = “Graph3-0.gif”,choices = [“GO”])
    arduino.write(“4”)
    main()


def demo3_4():
    message = “Does the car move further from points A to D or points F to H?”
    image = “Graph3.gif”
    title = “Question 4”
    choices = [“A to D”, “F to H”, “No difference”]
    B = eg.buttonbox(msg=message, title=title, choices=choices, image=image)
    if B == “F to H” or B == “No difference” : #Wrong Answers
<span style=”font-family: ‘Helvetica Neue’, Helvetica, Ar

Comments Off on The Code



Comments are closed.

  • Projects

    • 2017
      • Artistic Prosthetic
      • Cell Protobox Activity
        • Background
        • Overview and Lesson Plan
        • Pictures from the Activity
        • Final Prototypes from the Activity
        • Recount of the Activity
        • Demo Day with PDI Students
        • Final Protobox
        • Next Steps
        • Vision
      • Hue Harmony
        • Project Scope
          • HueHarmony2.ino
          • Sampler_12bit.ino
        • Future Development
        • User Feedback
        • Research
      • infinish.ed
        • Proposed Solution – Unfini-shed
        • Proposed Solution – infinish.ed
        • User Experience Mapping
        • Design Justification
        • Roadblocks/Challenges
        • User Feedback
        • Conclusion
      • Pop-Up Symphony
      • Saltwater Greenhouse
      • Smart Protection Brace
        • Background Research
        • Initial Prototype
        • Iterations and Second Prototype
        • Next Steps
        • Potential Methods
        • User Group
    • 2016
      • Creation Station: An Interactive Kiosk
        • User Group
        • Feedback #1: Oakwood Community Dinner-November 14th, 2016
        • Feedback #2: Uncle Sam’s Bus Stop-November 15th, 2016
        • Feedback #3: Farmer’s Market- November 19th, 2016
        • Prototype and Final Build of the Kiosk
        • Final Testing and Final Thoughts
      • ElektroTone
      • Furnäture
      • Media Sanctuary Mobile Experience
        • Prototype 1
        • Prototype 2
        • Prototype 3
        • Next Steps
        • Presentation Slides
      • ObservaStory
        • Background Research
        • First Iteration
        • Second Iteration
        • Evaluation & Dissemination
      • People Library
        • Target User Group
        • Primary Iteration: The Event
        • Secondary Iteration: The System
          • The Website
          • The App
        • User Feedback: The Process
        • The Final Product
      • Physics Plank
        • Physics Plank 1.0
          • Design
          • User Feedback
        • Physics Plank 2.0
          • Design
          • User Feedback
        • Next Steps
          • Ideal Code and Construction
      • Portable Foundation Finder (PFF)
        • Background Research
        • Customer Discovery
          • Personas
          • Survey Responses
        • Prototype
        • User Testing
        • Working Demo
    • 2015
      • Alien Adaptation
        • Target User Group
        • First School Visit (September 28, 2015) – Prototype #1
        • Second School Visit (October 15, 2015) – Prototype #2
        • Third School Visit (November 9, 2015) – Prototype #3
        • Fourth School Visit (December 10th, 2015) – Prototype #4
        • Background Research
        • Alien Cards
        • Methods of Organization
        • Other Resources
      • Zoe the Green Monkey
        • Background Research
        • Evaluation & Dissemination
        • Sources for Further Teaching
      • Recipe Ratios
        • School 2 Visits
        • Background Research and Information
        • Context
        • Evaluation & Assessment
      • Space Race
        • Background Research
        • Evaluation and Assessment
        • Field Work : 1st Visit to School 2
        • Field Work : 2nd Visit to School 2
        • Field Work : 3rd Visit to School 2
        • Field Work : Final Visit to School 2
      • Rhythmatic
        • Overview/Background Research
        • User Research & Design Specifications
        • Lesson Plan
        • User Testing
        • Ethnographic Observations
        • Final Interface Design
    • 2014
      • Ghanaian Solar Heat Collection
        • Solar Production of Adinkra Ink
          • Adinkra Ink Background Information
            • Interview with Mae-Ling Lokko
            • Production of Adinkra Ink
        • Solar Production of Biochar
          • Biochar Information
          • Heliostat Development
            • Codes and Hardware
            • Phase 1: Small setup
            • Phase 2: Medium Setup
            • Phase 3: Future Design Considerations
          • Interviews with Marianne Nyman and Alex Allen
          • Planning the process
          • Prototype Design Process Images
        • Prototype Iterations
        • Testing
        • Future Prospects
      • Cheap Sensors for Quality Education
        • Building the Sensor
        • CSnap Integration for Data Visualization
        • Future Work
        • Hardware
        • Previous Iterations
        • Professional Development Integration
          • Compost Computing PD Outline
        • Transferring Data from Arduino to CSnap
        • Code (Integration with SD card data collection)
          • SD Card Readout Example
        • Code (Temperature and Humidity sensors only)
      • Condom Vending Machine
        • Cultural Background
        • Why Open Source?
        • Screen Printing Vs. Stickers
          • Hints for stickers!
        • Intitial Design Ideas
          • Initial Designs
        • Prototypes and feedback
        • Final Design
        • Feedback
        • Future Plans
      • Music & Sound: Earthquake Simulator
        • Prototyping & Iterations
          • Rounds 1 & 2
          • Round 3: Final Prototype
        • Field-Testing: User Feedback
        • How-To/DIY Projects
        • Future Testing
        • Dissemination
    • 2013
      • Edu-Ponics
        • The Community Garden
        • The Tower
        • The Monitoring Unit
          • Code
          • Prototype
        • Dissemination
        • User Feedback
        • About
      • Fraction Bot
        • Future Iterations
        • Primary Market Research
        • Prototyping/Testing
        • Source Code–Please Use
      • Ghana Outreach Solar Reflector
        • Cultural Background
        • Partnership with KNUST
        • Prototyping
          • Initial Mock-up
          • Lamination
          • Plywood Model
          • Reaction Chamber
          • Stainless Steel Ribs
        • Testing
        • Future Iterations
      • iQube
      • Lean Green Clean Machine
        • Background
        • Redesign Proposal
      • Music Factory
        • Prototype
        • Field Testing
        • Dissemination
      • Nutrition Kitchen
        • The Game
        • Learning About Nutrition
        • Children’s Reactions and Results
      • Solar Tracker
    • 2012
      • 2 Fast, 2 Curious
        • Learning Objectives
        • Make It Yourself!
          • Hardware
          • The Code
        • Responses
        • The Game
        • Downloads
      • Apollo 2 1/4
        • Children’s Reactions
        • Final Trip Notes
        • Fraction Practice
        • Materials & Software Used
        • Source Code
      • Coordinate Kinection
        • The Game
          • How to Play
          • Screenshots
        • Student Reactions
        • Do It Yourself
          • main.cpp
          • Instructions
          • Download
      • Discover The Universe
      • Power Up!
        • Make Your Own
        • Platform Theory
          • Software Theory
        • Research and Development
        • Student Reaction
      • Squid Learn
        • Building the Lesson Plan
        • How It’s Made
        • Research and Iterations
          • 1st Visit
          • 2nd Visit
          • 3rd Visit
        • Student Reactions
    • 2011
      • Alien Frontier
        • Downloads
        • The Process
          • Ethnographic Description
          • Ethnographic Description 1
          • Ethnographic Description 2
      • Cookie Creations
        • Cookie Creation Game
        • Classroom Process
        • Assessments and Surveys Used
        • Research
      • Fast Track
        • DIY
        • Learning Objectives
        • Materials
        • Response
        • Components
      • Make ’em Fresh
        • Make ’em Fresh: How It’s Made
          • Team Contributions
        • Make ’em Fresh: Research and Iterations
          • Early Concepts
          • Images: First and Second Visits
          • Future Iterations
        • Make ’em Fresh: Student Response
          • Pre- and Post-Testing
      • Rap Star
        • The Game
          • What?
          • When & Where?
          • Who?
          • Why?
        • Field Testing and Iterations
          • First Visit
          • Second Visit
          • Final Visit
          • Ethnographic Descriptions
        • What Now?
          • Conclusion
          • Future Iterations
          • Additional Images
      • Rush More
      • School House of Pop
        • Educational Goals
        • Student Response
        • Design Evolution
        • Future Design Aspirations
        • Culture and Society
        • Pictures at School

Theme: MistyLook by Sadish. WPMU Theme pack by WPMU-DEV.