Skip to content

Instantly share code, notes, and snippets.

/*
This is an arduino timer that will
automatically log you out of your computer
***beware of unsaved files!!!***
Screen Timer v2
Author: James Shih
references
https://www.arduino.cc/en/Reference/KeyboardModifiers
https://www.arduino.cc/en/Reference/KeyboardPress
*/
/*
Screen Timer v1
Author: James Shih
references
https://www.arduino.cc/en/Reference/KeyboardModifiers
https://www.arduino.cc/en/Reference/KeyboardPress
*/
#include <Keyboard.h>
#include <HID.h>
var data = {
"computer":{
"tuesday": {
"page":438,
"general_use":3480,
"steam_cs":1560
},
"wednesday":{
"general_use":2948
},
<?php
$host = 'localhost';
$user = 'root';
$pass = 'toor';
@mysql_connect($host,$user,$pass) or die('Connection failed');
@mysql_select_db('cycle');
//echo 'good';
$sql = mysql_query("SELECT * FROM data ORDER BY ID ASC");
$id = 'ID';
$date = 'Date';
create table data (
ID int(11) AUTO_INCREMENT NOT NULL,
Date char(255) NOT NULL,
Time char(255) NOT NULL,
Status char(3) NOT NULL,
Position int(11) NOT NULL,
constraint data_PK primary key (ID)
);
#ref:http://www.instructables.com/id/Interface-Arduino-to-MySQL-using-Python/?ALLSTEPS
import MySQLdb
import serial.tools.list_ports
db = MySQLdb.connect("localhost","root","toor","cycle") or die ("connection failed")
cursor = db.cursor();
ports = list(serial.tools.list_ports.comports())
for p in ports:
if "ttyACM" in p[1]: #fpr raspi
#if "Arduino" in p[1]: #for mac
arduino = serial.Serial('/dev'+p[1],9600,timeout = .1) #for raspi
#include "FastLED.h"
#include "DS3231.h"
#define NUM_LEDS 24
#define DATA_PIN 8
#define CLOCK_PIN 9
int pos;
int hue;
unsigned long pTime;
unsigned long dTime;
int potVal;
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1280,800,OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
#include "ofApp.h"
ofNode base;
ofNode secondNode;
ofNode thirdNode;
ofPolyline line;
ofEasyCam cam;
ofSerial serial;
float a;
#include "FastLED.h"
#define NUM_LEDS 15
#define DATA_PIN 8
#define CLOCK_PIN 9
#define BUTTON_PIN 2
CRGB leds[NUM_LEDS];
int val;
int counter;
int caseState;
unsigned long pTime;