For our ESE 190 project, we took a need (temperature and light sensing on surgical tools during murine craniotomies) and engineered a solution (an easy to use, Arduino-based photoresistor + temperature sensing module that can be mounted on a scalpel). This module incorporates flashing LEDs as a feedback system. Since it runs on Arduino, the code is open sourced and the components are super cheap. The hope is to use this design to inspire others to tackle this challenge in more innovative ways.

CODE:

const int sensorPin = 0; const int temperaturePin = 1; const int ledPin1 = 9; const int ledPin2 = 10;

// We'll also set up some global variables for the light level: int lightLevel; int calibratedlightLevel; // used to store the scaled / calibrated lightLevel int maxThreshold = 0; // used for setting the "max" light level int minThreshold = 1023; // used for setting the "min" light level int voltage1= 0; int voltage2= 5; void setup() { pinMode(9, OUTPUT); pinMode(10, OUTPUT); Serial.begin(9600); // more light for photoresistor means brighter LED // more heat for temp sensor means brighter LED }

void loop() { digitalWrite(9, LOW); // Turn on the LEDs digitalWrite(10, LOW);

lightLevel = analogRead(sensorPin); // reads the voltage on the sensorPin Serial.print(lightLevel);

calibratedlightLevel = map(lightLevel, 0, 1023, 0, 255);
Serial.print("\t");
Serial.print(calibratedlightLevel);

analogWrite(9, calibratedlightLevel);

float voltage, voltage1, degreesC, degreesF; //Declare floating point variables

voltage = analogRead(temperaturePin); //Measure the voltage at the analog pin

delay(3000);

// voltage1= analogRead(temperaturePin);

if (voltage2 > voltage1) digitalWrite(10, HIGH);

delay(5000); } void autoRange() { if (lightLevel < minThreshold) // minThreshold was initialized to 1023 -- so, if it's less, reset the threshold level. minThreshold = lightLevel;

if (lightLevel > maxThreshold) // maxThreshold was initialized to 0 -- so, if it's bigger, reset the threshold level. maxThreshold = lightLevel;

lightLevel = map(lightLevel, minThreshold, maxThreshold, 0, 255); lightLevel = constrain(lightLevel, 0, 255); }

Built With

Share this project:

Updates