Making Things Interactive

May 10, 2008

Digital Book Reader

Filed under: Final Project,Nadeem Haidary — nhaidary @ 6:05 pm
Tags:

This simulation of an electronic book reader promotes active reading by harnessing the computing and human power. It uses page-turning gestures to generate the power necessary to update an electronic paper screen. Using gestures provides cognitive, mechanical and digital feedback to the person using the device.

In these demonstrations, rotating the page generates power (as indicated by the LEDs) and displays a new page after a 180 degree rotation.

The second prototype provides an alternative method of turning pages.

And if anyone is interested:

Bibliofile – poster

Bibliofile – presentation

Arduino code:


/*
 *   Digital Book Reader
 *   Final Project
 *   Spring 2008
 *
 *   Nadeem Haidary
 */

//LIBRARIES

//GLOBAL VARIABLES
//pins
int motorPin = 0;                   // motor is connected to pin 0
int mDirectionPin = 1;              // motor is also connected to pin 1
int potPin = 2;                     // potentiometer is connected to pin 2
int rotatePin = 8;                  // the rotation reading switch is connected to pin 8
int LEDPin1 = 9;                    // LED is connected to pin 9
int LEDPin2 = 10;                   // LED is connected to pin 10
int LEDPin3 = 11;                   // LED is connected to pin 11

int potValue;                       // the value read from the potentiometer
int motorValue;                     // the value read from the motor
int tiltValue;                      // the value read from the tilt switch
int currentFlip;                    // the current tilt value
int previousFlip;                   // the state of the tilt switch
int motorDirection;                 // the direction of the motor read without a diode bridge

//---SETUP-------------------------------------------------------------->

void setup() {
  pinMode(motorPin, INPUT);         // Set the motor pin as an input
  pinMode(mDirectionPin, INPUT);    // Set the motor direction pin as an input
  pinMode(LEDPin1, OUTPUT);         // Set the LED pin as an output
  pinMode(LEDPin2, OUTPUT);         // Set the LED pin as an output
  pinMode(LEDPin3, OUTPUT);         // Set the LED pin as an output
  pinMode(rotatePin, INPUT);        // Set the rotate switch pin as an input

  previousFlip = HIGH;   // Read the original state of rotation

    Serial.begin(9600);             // Start serial communications
}

//---LOOP--------------------------------------------------------------->

void loop(){

  //READING THE MOTOR TO GENERATE POWER
  motorValue = analogRead(motorPin);      // Read the motor pin as an analog input
  //Serial.println(motorValue);           // Print motor value

  potValue = analogRead(potPin) / 6.71;   // Read the potentiometer pin and scale from 0-100
  //Serial.println(potValue);               // Print it

  motorDirection = analogRead(mDirectionPin);
  //Serial.println(motorDirection);

  if (motorDirection > 0) {
    if (motorDirection < 10) {                  // Three LED's turn on in sequence depending
      digitalWrite(LEDPin1, HIGH);           // on how much power is being delivered by the motor
      digitalWrite(LEDPin2, LOW);
      digitalWrite(LEDPin3, LOW);
    }
    else if (motorDirection < 50) {
      digitalWrite(LEDPin1, HIGH);
      digitalWrite(LEDPin2, HIGH);
      digitalWrite(LEDPin3, LOW);
    }
    else {
      digitalWrite(LEDPin1, HIGH);
      digitalWrite(LEDPin2, HIGH);
      digitalWrite(LEDPin3, HIGH);
    }
  }
  else {
    digitalWrite(LEDPin1, LOW);
    digitalWrite(LEDPin2, LOW);
    digitalWrite(LEDPin3, LOW);
  }

  flipper();

}

//---FUNCTIONS----------------------------------------------------------->

void flipper() {

  //USING A MOTOR AND SWITCH TO CHANGE PAGES
  currentFlip = digitalRead(rotatePin);   // Read the state of rotation
  //Serial.println(currentFlip);

  if (currentFlip != previousFlip) {
    if (currentFlip == HIGH) {
      if (potValue > 90) {
        Serial.print(2, BYTE);
      }
      else if (potValue <= 90 && potValue > 15) {
        Serial.print(3, BYTE);
      }
      else {
      //Serial.println("hello");
      Serial.print(1, BYTE);
      }
    }
  }

  previousFlip = currentFlip;
}

Processing code:

/*
* Digital Book Reader
* Final Project
* Spring 2008
*
* Nadeem Haidary
*/

//LIBRARIES
import processing.serial.*;

//GLOBAL VARIABLES
PFont title; // title font
PFont font; // text font
Serial port; // Create object from Serial class
int val; // Data received from the serial port
int x = 0; // stores nothing important right now
int page = 0; // page number
int spacer = 0; // tracks line number within loop
int lineStart = -46; // line that page starts at
int lineEnd = 0; // line that page ends at
int linesPerPage = 46; // the total amount of lines dispalyed up until a certain page
boolean saveImage = false; // for saving a frame

void setup() {
size (700, 800);
frameRate(10);

println(Serial.list()); // Set up the serial communication
port = new Serial(this, Serial.list()[1], 9600); // Open the port that the board is connected to (in this case COM4 = [1])
// and use the same speed (9600 bps)

font = loadFont(“BookAntiqua-10.vlw”);
title = loadFont(“BookAntiqua-BoldItalic-48.vlw”);
String lines[] = loadStrings(“ulysses_text only.txt”); // Loads the book from a text file and seperates each line into a String in an array
println(“there are ” + lines.length + ” lines”); // prints the number of lines
}

void draw() {
background (250); // sets the background color
fill (0); // sets the text color
smooth(); // anti-aliasing
String lines[] = loadStrings(“ulysses_text only.txt”); // for some reason, the only way I can get this to work is by reloading the strings every frame

if (0 < port.available()) { // If data is available, val = port.read(); // read it and store it in val } println(val); if (val == 1) { delay(40); page ++; lineStart += linesPerPage; lineEnd += linesPerPage; } if (val == 2) { delay(40); page = page + 50; lineStart += (linesPerPage * 50); lineEnd += (linesPerPage * 50); } if (val == 3) { delay(40); page = page + 10; lineStart += (linesPerPage * 10); lineEnd += (linesPerPage * 10); } if (val == 1 || val == 2 || val == 3) { val = 0; } /* // NAVIGATION if (keyPressed == true){ if (key == '.') { // press the > key to advance a page
delay(40);
page ++;
lineStart += linesPerPage;
lineEnd += linesPerPage;
}
if (key == ‘,’ && page > 0) { // press the < key to go back a page delay(40); page--; lineStart -= linesPerPage; lineEnd -= linesPerPage; } if (key == 's') { // press the s key to save a frame saveImage = true; } //println(lineStart + " " + lineEnd); } */ if (page == 0) { // display title page textFont(title, 48); // sets the type to be used text("Ulysses", 250, 522); textFont(title, 18); text("James Joyce", 255, 480); } else { // display text pages textFont(font, 10); spacer = 0; for (int i=lineStart; i < lineEnd; i++) { // display all the lines for this page text(lines[i], 20, 30 + (spacer*12)); // starting corner and spaces between lines spacer++; // count the lines } textFont(title, 24); text(page, 400, 20); // display page number } if (saveImage == true) { // save a frame save("page.tif"); } } [/sourcecode]

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: