Tuesday, March 18, 2014

Human as pests

I have begun creating my project. I used the same fritzing schematic that I used in the voltage divider tutorial that is also on a previous blog post of mine. Instead of a potentiometer, I used photocells stringed together. I programed an led to blink in the same fashion as a pulse. Instead of a simple on-off-on-off pulse, I have written the code to blink in an on-off(pause)on-off. To increase the speed of the heart beat, I made the delay of each two beats to read the sensor information. I also included a light at the top of the container, so that the shadow of the bug is what will trigger the increase of pulse speed. This is what my code looks like:

int sensorValue = 0;
int sensorPin = A0;

void setup() {
Serial.begin(9600);
 
  pinMode(9, OUTPUT);    
}

void loop() {
  sensorValue = analogRead(sensorPin);
  digitalWrite(9, HIGH);
  delay(150);
  digitalWrite(9, LOW);  
  delay(150);
digitalWrite(9, HIGH);
  delay(150);          
  digitalWrite(9, LOW);  
  delay(sensorValue);  
  Serial.println(sensorValue);
}

This is what my circuit looks like on the breadboard:

I wired everything to a circuit board and after trial and tribulation, the circuit works. However I have not caught an insect to see if the final product really works in relation to my concept.


No comments:

Post a Comment