Saturday, June 13, 2020
Capsense Exploration
Processing Experimentation
size(640, 360);
}
background(200,0,0); // background color
pushMatrix(); // left star
fill(204, 102, 0); // not sure how to change individual colors?
translate(width*0.2, height*0.5);
rotate(frameCount / 50.0); // increased rotation
star(0, 0, 20, 70, 6); //increased number of corners
popMatrix();
pushMatrix(); // center star
translate(width*0.5, height*0.5);
rotate(frameCount / 400.0);
star(0, 0, 80, 100, 40);
popMatrix();
pushMatrix(); // right star
translate(width*0.8, height*0.5);
rotate(frameCount / -100.0);
star(0, 0, 50, 70, 8);
popMatrix();
}
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}
int lastBar = -1;
{
size(640, 640); // change canvas size
colorMode(HSB, height, height, height);
noStroke();
background(0);
}
{
int whichBar = mouseY / barWidth; //mouse moves up and down and changes color
if (whichBar != lastBar) {
int barX = whichBar * barWidth;
fill(mouseY, height, height);
rect(barX, 0, barWidth, height);
lastBar = whichBar;
}
}
Analog Output Experimentation
Final SPA Documentation: A Rick Roll Box
Final Prank Documentation
Analog Output Experimentation
I'm still trying to figure out this project, but hopefully I learn my mistake soon!
const int ledPin = 9;
const int ldrPin = A0;
int brightness = 0;
int fadeAmount = 5;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 400) {
analogWrite(ledPin, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);;
}
else {
digitalWrite (ledPin, LOW);
}
}
Capsense Library Experimentation
The code I used was the Capacitive Sensor Sketch example from the Capsense Library.
Final Prank Documentation
Capsense Library
Capacitive Sensing
This was quite interesting as I got to understand the value of capacitive sensing and can recognize the technologies that possibly use this type of sensing. I used a 1M ohm resistor and connected it to my x-acto knife. The serial monitor was still confusing to read because of the unstable grounding but I was able to witness the changes in the readings so I'm happy it was evidently working.
My code:
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
void setup(){
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600);
}
void loop(){
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug window spacing
Serial.println(total1); // print sensor output 1
delay(10); // arbitrary delay to limit data to serial port
}
Knolling a Film Camera
Analog Output Experimentation
Add caption |
Friday, June 12, 2020
SPA Project: Humidity/Temperature Detector
Final Prank Documentation
I decided to try to use Arduino to surprise tickle people when they sit at their desk. How diabolical!
Circuit
I had a couple of ideas for how to sense the pranked person when they sat at their desk, such as light fluctuations and motion detection, but eventually I settled on using light for simplicity's sake. Thus, I began this project by setting up the servo motor and then integrating the photoresistor into the circuit.
Initial Code
#include <Servo.h>
Servo servo1;
void setup() {
// set the servo pin, pin 9, as a servo output pin
servo1.attach(9);
}
void loop() {
//Read the light value from the photoresistor
int lightValue = analogRead(A0);
// map the light readings to the angle possible by the servo motor
lightValue = map (lightValue, 0, 1023, 0, 180);
// control the servo motor based on the light value read, adjust linearly by angles
servo1.write(lightValue);
}
Progress!
I was able to successfully use the light values detected by the photoresistor to determine the angle of the servo rotation.