Pressure Warning Sensor

As the title tells you, I made a light bulb that changes its colour (and maybe you could say action?) when the pressure sensor is applied with different strength. Here is a short video for the warning sensor in action!

 

I made this warning sensor because I wanted to make something useful rather than entertaining, as the previous two were something to do with entertainment. And then I was looking for inspirations from other students’ work, and saw one that changes colours when different voltage is applied to the colour-varying lightbulb, and that clicked my mind.

 

Here is the coding for this warning sensor.

int potPin = A0;
int redLED = 2;
int greenLED = 3;
int blueLED = 4;
int sensorVal;

void setup() {
  pinMode(greenLED, OUTPUT);
  pinMode(blueLED, OUTPUT);
  pinMode(redLED, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 sensorVal = analogRead(potPin);
 
 if(sensorVal>900) {
  digitalWrite(redLED, HIGH);
  delay(200);
  digitalWrite(redLED,LOW);
  delay(200);
 }

 if(sensorVal<900 && sensorVal>400) {
  digitalWrite(greenLED, HIGH);
  digitalWrite(redLED, HIGH);
 }
 if(sensorVal<400) {
  digitalWrite(blueLED, HIGH);
 }
 
 else{
  digitalWrite(redLED, LOW);
  digitalWrite(blueLED, LOW);
  digitalWrite(greenLED, LOW);
 }
}

This basically means as follow: when the pressure that equates to less than 400 will give blue colour, which means safe; when the pressure is somewhere between more than 400 to less than 900, it will give a mixed colour of green and red, which is supposed to be yellow; and when the pressure is more than 900, there will be a blinking red light.

The problem here is that the lightbulb does not give yellow light when the mild pressure is applied. It can be due to the lightbulb itself and with further experimentation (trial & error), I might be able to find a colour that is like yellow.

Another problem is that pressure sensor is not that accurate, which is not something I can control I guess (besides bending which seemed to make it work better).

Here is a further reference to what I have made.

Photo on 9-21-15 at 12.25 AM #3

Leave a Reply