index2018-12-11

anti-capitalist computer mouse

Description
The anti-capitalist computer mouse functions almost exactly like any other computer mouse. It is built on top of an old mechanical roller ball PS/2 mouse. The PS2 connector of the mouse is wired directly into an Arduino Micro which is sitting inside of the body of the mouse. A future version of the anti-capitalist mouse will not let a person buy anything on the internet. In its current state it will encourage a user to become overly aware of the presence of advertisements by setting off a vibrating motor, also wired into the Arduino Micro, each time the mouse passes over one.

Description of example uses
The anti-capitalist computer mouse is a think piece. What does it mean to be physically alerted to something on a computer screen? How can this be useful? Is the immaterial labor of browsing the internet in exchange for “free” tools and information ok? How can capitalism be eroded? The anti-capitalist computer mouse can be used with any computer for any navigational purpose and can perhaps help someone to finally stop buying things on Amazon.







Ups and Downs

See “Documentation of Failures”


Circuit Schematic
standard-graphing-paper

There are two main components to speak of. The first is the PS/2 Connector. This connector comes with 6 wires. The green wire is for power, the black wire is for ground, the yellow wire is the clock, and the brown wire is the data.

You might be wondering…what is clock?? what is data?? The PS/2 protocol has two main signals. The data line outputs a serial frame of bits as it toggles the clock line once for each bit. More info here.

The second component is the DC Motor. For a seemingly simple component the circuitry is actually kind of complex! To start we needed a PN2222 Transistor, a 270 ohms Resistor, and a 1N4001 diode.

If we are using a horizontally wired breadboard the wiring should be as follows:

There is one wire from 5V power to one leg of the DC Motor. On the other side of this DC Motor leg is the right leg of the diode.

The other leg of the DC Motor is connected to the left leg of the diode which is also connected to the right leg of the transistor.

The middle leg of the transistor is connected to the right leg of the resistor.

The left leg of the transistor is connected to ground.

Finally there is a wire connecting the left leg of the resistor to Digital Pin 3.

Image with these same details below:

IMG 4292



Microcontroller Code

/*
PS2 Connector Wires
Green Wire - 5V
Black Wire - GRND
Yellow Wire - Clock - Pin 6
Brown Wire - Data - Pin 5
*/

#include "PS2Mouse.h"
#include "Mouse.h"

PS2Mouse oldMouse(6,5);

int count = 0;
int capitalism;
int motorPin = 3;
bool isClicked = false;

void setup(){
  Serial.begin(9600); 
  pinMode(motorPin, OUTPUT);
  oldMouse.begin();
  Mouse.begin();
}

void loop() {
  uint8_t stat;
  int x,y;
  int newY;
  
  oldMouse.getPosition(stat,x,y);

  if (y < 0) { newY = abs(y); } 
  if (y > 0) { newY = -y; }
  if (y == 0) { newY = y; }
  
  Mouse.move(x, newY, 0);
  
  if (stat == 9 && isClicked == false) {
    Mouse.click();
    isClicked = true;    
  }
  
  if (stat != 9) { isClicked = false; }
  
  if (Serial.available() > 0) {
    capitalism = Serial.read();

    if (capitalism == 'x') {
      digitalWrite(3, HIGH);
      delay(400);
      digitalWrite(3, LOW);
      
      if (count < 1) {
        Mouse.move(100,100,0);
        count += 1;
      } else {
        count = 0;
      }
    }
  }
}




Node Server Code

/*
adapted from Simple Serial Server by Tom Igoe
*/

var SerialPort = require('serialport');		
var	portName = "/dev/cu.usbmodemHIDGD1";
var express = require('express');
var server = express();	
var myParser = require("body-parser");
let myPort;

let opened = false;

open();

server.use( myParser.json());
server.listen(8080);   

server.use(myParser.urlencoded({extended : true}));

server.post("/posts", function(request, response) {
  if (myPort) {
    console.log(request.body.data);
    myPort.write('x');
  }
});

function open() {
  myPort = new SerialPort(portName, 9600);
  myPort.on('open', showPortOpen);  
  myPort.on('close', showPortClose);
  myPort.on('error', showError); 

  if (!opened) {
    setTimeout(function() {
      if (!opened) {
        open();
      }
    }, 2000);
  }
}

function showPortOpen() {
  console.log('port open. Data rate: ' + myPort.baudRate);
  opened = true;
}

function showPortClose() {
  console.log('port closed.');
  opened = false;
  open();
}

function showError(error) {
  console.log('Serial port error: ' + error);
}




Browser Extension Code

let wholeArray = [];

var ads = document.getElementsByClassName('ad');
var cads = document.getElementsByClassName('c-ad');
var containers = document.getElementsByClassName('ad-container');
var topBanners = document.getElementsByClassName('top-banner-ad-container');
var adAware = document.getElementsByClassName('ad-awareness-wrapper');
var adWire = document.getElementsByClassName('ad-wireframe-wrapper');
var iframe = document.getElementsByTagName('iframe');
var adSlot = document.getElementsByClassName('ad-slot-container');
var jsBanners = document.getElementsByClassName('js-top-banner');
var google = document.getElementsByClassName('GoogleActiveViewClass');


wholeArray.push(ads, cads, containers, topBanners, adAware, adWire, iframe, adSlot, jsBanners, google);

for (var i = 0; i < wholeArray.length; i++) {
  changeElement(wholeArray[i]);
}

function changeElement(el) {
  if (el) {
    console.log("FOUND", el.length, "ADVERTISEMENTS");

    for (var i = 0; i < el.length; i++) {
      if ( el[i].addEventListener ) {
        el[i].addEventListener("mouseover", mouseOver);
      }
    }
  }
}

function mouseOver() {
  sendPost();
}

function sendPost(dat) {
  let timer;

  clearTimeout(timer);
  timer = setTimeout(function() {
      console.log('sent');
      $.ajax({
        url: "http://localhost:8080/posts",
        type: "POST",
        data: JSON.stringify({
          "data": "We can bring to birth a new world from the ashes of the old ",
        }),
        error: function(e) {
          console.log(e);
        },
        dataType: "json",
        cache: false, 
        contentType: "application/json; charset=utf-8"
      });
  }, 100);
}




Research and References …coming soon