Last active
February 5, 2016 19:49
-
-
Save Nesciosquid/d9c08b1a1a42c65fb8c2 to your computer and use it in GitHub Desktop.
3D-Printable Light Sensors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = 30; | |
RESISTOR_LEAD_HOLE_DIAMETER = 1.3; | |
RESISTOR_LEAD_SPACING = 9; | |
RESISTOR_SPACING_OFFSET = 5; | |
PHOTORESISTOR_LEAD_HOLE_DIAMETER = 1.3; | |
PHOTORESISTOR_LEAD_SPACING = 4; | |
FIBER_CONNECTOR_SNAP_HOLE_DIAMETER = 2.3; | |
FIBER_CONNECTOR_SNAP_SPACING = 7.7; | |
FIBER_MOUNT_BLOCK_DEPTH = 1.2; | |
MOUNT_SPACING_BUFFER_X = 3; | |
MOUNT_SPACING_BUFFER_Y = 5; | |
FIBER_SMALL_HOLE_DIAMETER = 2.3; | |
FIBER_LARGE_HOLE_DIAMETER = 3.4; | |
FIBER_SMALL_HOLE_DEPTH = 1.2; | |
FIBER_LARGE_HOLE_DEPTH = 5; | |
LED_HOLE_DIAMETER = 5.2; | |
LEDHoleDepth = FIBER_SMALL_HOLE_DEPTH + FIBER_LARGE_HOLE_DEPTH; | |
TEST_PLATE_WIDTH = 30; | |
TEST_PLATE_HEIGHT = 30; | |
testPlateDepth = FIBER_LARGE_HOLE_DEPTH + FIBER_SMALL_HOLE_DEPTH; | |
mountSpacingX = MOUNT_SPACING_BUFFER_X + FIBER_CONNECTOR_SNAP_SPACING + MOUNT_SPACING_BUFFER_X; | |
mountSpacingY = MOUNT_SPACING_BUFFER_Y + RESISTOR_SPACING_OFFSET + MOUNT_SPACING_BUFFER_Y; | |
//fiberTestPlate(); | |
fiberMountBlock(3); | |
module LEDHole(){ | |
cylinder(LEDHoleDepth, d=LED_HOLE_DIAMETER, false); | |
} | |
module testPlateBase(){ | |
cube([TEST_PLATE_WIDTH, TEST_PLATE_HEIGHT, testPlateDepth]); | |
} | |
module fiberTestPlate(){ | |
difference(){ | |
testPlateBase(); | |
translate([5,5,0]){ | |
fiberHole(); | |
translate([6,0,0]){ | |
LEDHole(); | |
} | |
} | |
translate([TEST_PLATE_WIDTH-5,5,0]){ | |
fiberHole(); | |
translate([0,6,0]){ | |
LEDHole(); | |
} | |
} | |
translate([5,TEST_PLATE_HEIGHT-5,0]){ | |
fiberHole(); | |
translate([6,0,0]){ | |
LEDHole(); | |
} | |
} | |
} | |
} | |
module fiberHole(){ | |
cylinder(FIBER_SMALL_HOLE_DEPTH, d=FIBER_SMALL_HOLE_DIAMETER, false); | |
translate([0,0,FIBER_SMALL_HOLE_DEPTH]){ | |
cylinder(FIBER_LARGE_HOLE_DEPTH, d=FIBER_LARGE_HOLE_DIAMETER, false); | |
} | |
} | |
module fiberMountBlockHoles(count){ | |
for(i = [0:count-1]){ | |
xOff = mountSpacingX /2 + i * (mountSpacingX); | |
yOff = MOUNT_SPACING_BUFFER_Y; | |
translate([xOff, yOff, 0]){ | |
fiberMount(); | |
} | |
} | |
} | |
module fiberMountBlock(count){ | |
difference(){ | |
fiberMountBlockBase(count); | |
fiberMountBlockHoles(count); | |
} | |
} | |
module fiberMountBlockBase(count){ | |
blockWidth = mountSpacingX * (count); | |
blockHeight = mountSpacingY; | |
cube([blockWidth, blockHeight, FIBER_MOUNT_BLOCK_DEPTH]); | |
} | |
module fiberMount(){ | |
rotate([0,0,90]){ | |
holePair(PHOTORESISTOR_LEAD_HOLE_DIAMETER, PHOTORESISTOR_LEAD_SPACING); | |
} | |
holePair(FIBER_CONNECTOR_SNAP_HOLE_DIAMETER, FIBER_CONNECTOR_SNAP_SPACING); | |
translate([0,RESISTOR_SPACING_OFFSET, 0]){ | |
holePair(RESISTOR_LEAD_HOLE_DIAMETER, RESISTOR_LEAD_SPACING); | |
} | |
} | |
module holePair(diameter, distance){ | |
translate([-distance/2,0,0]){ | |
cylinder(20, d=diameter, center= true); | |
} | |
translate([distance/2, 0,0]){ | |
cylinder(20, d=diameter, center=true); | |
} | |
} | |
module holeArray(start, step, offset, count){ | |
for (i = [0:count-1]){ | |
width = start + i * step; | |
off = offset * i; | |
translate([off,0,0]){ | |
cylinder(20, d=width, center=true); | |
} | |
} | |
} | |
module throughHoles(){ | |
holeArray(3, .2, 10, 5); | |
translate([0,7,0]){ | |
holeArray(4, .2, 10,5); | |
} | |
} | |
// resistor leads: 1.2 mm | |
// fiber connector snap: 2.2 mm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Photocell simple testing sketch. Adapted from Adafruit's excellent instructions at https://learn.adafruit.com/photocells/using-a-photocell: | |
Connect one end of each photocell to 5V, the other end to an analog input. | |
Then connect one end of a 10K resistor from Analog 0 to ground | |
Connect LED from pin 11 through a resistor to ground | |
For more information see http://learn.adafruit.com/photocells */ | |
int photoPin0 = 1; | |
int photoPin1 = 2; | |
int photoPin2 = 3; | |
int LEDPin0 = 13; | |
int LEDPin1 = 12; | |
int LEDPin2 = 11; | |
int lightThreshold = 100; | |
int delayTime = 100; // microseconds, | |
void setup(void) { | |
// We'll send debugging information via the Serial monitor | |
Serial.begin(9600); | |
} | |
void loop(void) { | |
int read0 = analogRead(photoPin0); | |
int read1 = analogRead(photoPin1); | |
int read2 = analogRead(photoPin2); | |
//Print the current read to the serial console, for debugging/analysis | |
//Serial.println(read0); | |
if (read0 > lightThreshold) { | |
analogWrite(LEDPin0, 255); | |
} else { | |
analogWrite(LEDPin0, 0); | |
} | |
if (read1 > lightThreshold) { | |
analogWrite(LEDPin1, 255); | |
} else { | |
analogWrite(LEDPin1, 0); | |
} | |
if (read2 > lightThreshold) { | |
analogWrite(LEDPin2, 255); | |
} else { | |
analogWrite(LEDPin2, 0); | |
} | |
delayMicroseconds(delayTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment