231a-af Final Project Presentation

From CSclasswiki
Jump to: navigation, search

Final Project Presentation

Overview

The idea for my project was spawned from the countless hours that I spend in front of my computer, and the ensuing dizziness/eye strain. I looked up resources that recommended 15 minutes away from the computer for every hour spent in front of it. It would have been useful to have a system like that watching me, especially while I was working on this very project and spending far too much time staring at a tiny, blinking screen.

Original Project

  • My project will use a light sensitive resistor with the Arduino to sense how long you have been in front of the computer.
  • It will give you warnings if you remain in front of the computer for too long, and will welcome you back when you return.
  • After one hour in front of the computer, you should take a 15 minute break.
  • It will run continuously until the user chooses to exit the program, at which time statistics for that period's computer use will be displayed.
  • All the user's action's will be recorded in an external file - data will be stored on when the user begins the program, each time the user leaves and returns to the computer, length of time that user is at or away from the computer, and the final ratio of computer use.

Final Project - Alpha Stage

  • My project uses an infrared proximity sensor with the Arduino to sense how long you have been in front of the computer.
    • I use the Sharp GP2Y0A21YK.
  • It will count down the time you have left remaining either at or away from the computer.
    • I was not able to get aplay to work in the amount of time that I had, nor did printing 0x07 work.
  • After one minute in front of the computer, you should take a 15 second break.
    • This simplification was done for the 10 minute presentation.
  • It will run for 8 minutes, at which time the program will end.
    • I was trying to find ways to do non-blocking input, but did not fully understand the sources that I found, so did not implement. (For more information, see here.)
  • Information is stored to data.txt, but I did not have time to fully flesh out the file I/O.
    • The only data stored in the file is when the user begins the program, and the numbers can only be read in an octal dump because I was unable to figure out how to convert the number into a series of ascii numbers to display in the data file.

Hardware

  • GP2Y0A21YK is an IR sensor from Sharp. This sensor takes a continuous distance reading and returns a corresponding analog voltage with a range of 10cm (4") to 80cm (30").
  • Schematics:

231a-afGP2Y0A21YKschematics-updated.jpg

  • I first tested my hardware using the Arduino IDE to interface with my Arduino.
    • First, I used the serial monitor to watch how input from the sensor changed with different conditions.
      • I discovered that typically, the input will give a reading >100 if it detects an object within its range, and the reading will drop below 100, usually fluctuating between 30-60, when no object is detected within its range.
    • I then created a program in the Arduino IDE to turn the Pin 13 LED on/off when the sensor detected an object in front of it. The code for that program is shown here.

Software

Arduino

  • On my Arduino, I used an unedited copy of the arduino_loop.pde code that we used in Lab 7.

C program

  • For the C program, I used an unedited copy of the arduino-serial.c program that we used in Lab 7.

Assembly

  • I edited the talkToArduino program that we developed in Lab 7, and tweaked it so that it would fit my purposes. Code for my final program is located here.
  • The program stores information on the user's most recent activities, but this version has no long term memory.


Creation of the talkToArduino program:

  • Step 1: Use assembly to accomplish the same results as the Arduino IDE (see functions: readPin1, setPin13)
  • Step 2: Handle time of day instructions (see function: timeOfDay)
  • Step 3: Let program understand when situation has changed states - user has just left, or just returned (see function: changeState)
  • Step 4: Update the counters associated with being either at or away from the computer (see function: update)
  • Step 5: Configure program to respond to processed information - certain amount of time at the computer, certain amount of time away from the computer allowed (see function: monitor)
  • Step 6: Print to the screen in a more appealing fashion - ANSI sequences (see function: clrScreen)
  • Step 7: Work on outputting all the information to an external data file (see function: writeToFile)


Proposed future modifications:

  • Fix all the missing elements
    • Keep a running tally of the total length of time the user spends away from/at the computer
    • Output the final total statistics when the program ends
    • Note all activities in the external file
    • Use non-blocking input
    • Use sound warnings
  • Calibrate sensitivity of the sensor (currently processing information once per second, rework so that it processes information more often, but stores some sort of buffer so that brief sensor quirks are ignored)
  • Allow the program more access to the computer - not only give warnings, but block access to the computer once the time limit has passed
  • Figure out a better way to attach the proximity sensor to the computer

Navigation

Return to Main Page
Project Ideas
Project Proposal
Project Software Description