Touch me not !

Description: 

Well everyone must have seen the touch me not leaves which close when touched. I tried to create something similar but a different reaction to the touch. I created an origami lily and attached the stalk to the dc motor. On the flower is a photo sensor that detects if a hand is close to the petals. When close, the dc motor gets activated and moves the flower in order to depict that the flower is not meant to be plucked.

Components:

  • Arduino Uno
  • 1 DC motor
  • 1 Transistor
  • 1 Diode
  • 2 resistors (one 1KΩ, one 10KΩ)
  • 1 photo sensor
  • 1 piezo sensor
  • 1 origami lily
  • battery pack
  • two AA batteries
  • jumper wires

Code:

// This code is to move the DC motor based on input from a photosensor

const int dcMotorPin = 11;
const int piezoPin = 7;
const int photPin = 1;

int photValue;
int dcMotorValue;
int potValueBeats;

void setup() {
// Still need to set a baud rate, even for USB.
Serial.begin(9600);
// Set DC Motor and Piezo pins to output.
pinMode(dcMotorPin, OUTPUT);
pinMode(piezoPin, OUTPUT);

// photo sensor analogue pin is an input.
pinMode(photPin, INPUT);
}

void loop() {
// The photo sensor values are mapped from 300 to 1024 onto 0 to 150
photValue = analogRead(photPin);

if(photValue <= 300) { dcMotorValue = 150; } else if(photValue > 300 && photValue < 700)
{
dcMotorValue = 70;
}
else
{
dcMotorValue = 0;
}

analogWrite(dcMotorPin,dcMotorValue);
digitalWrite(piezoPin, HIGH);
delayMicroseconds(956);
digitalWrite(piezoPin, LOW);
delayMicroseconds(956);
}

img_20161011_174648
 

Leave a Reply