Skills Dev 2

Made by Tianyi He · HIDDEN

Created: December 18th, 2023

This project is unlisted and only folks with the link can see it. Be considerate and think twice before sharing.

0

Process

This project is composed of four main components: a bend sensor, a photoresistor, a LED, and a buzzer. The bend sensor operates within a range of 150 to 500, while the photoresistor functions in a range of 2000 to 4000. When the bend sensor value is solely below 250, the LED will light up for 1.5 seconds and then turn off for 0.5 seconds. Conversely, when only the photoresistor value falls below 100, the LED will be on for 0.5 seconds and off for 1.5 seconds. If both values are below their respective thresholds, the buzzer will be activated and start beeping.

0

Outcome

0
int photoCellPin = A0;
int bendPin = A1;
int buzzerPin = D3;
int photoCellReading = 0;
int bendReading = 0;

int ledPin = D2;

int ledBrightness = 0;

void setup() {
    pinMode(bendPin, INPUT);
    pinMode(photoCellPin, INPUT);
    pinMode(ledPin, OUTPUT);
    pinMode(buzzerPin, OUTPUT);
    Particle.variable("light", &photoCellReading, INT);
    Particle.variable("bend", &bendReading, INT);

}

void loop() {
  photoCellReading = analogRead(photoCellPin);
  bendReading = analogRead(bendPin);
  ledBrightness = map(photoCellReading, 2800, 4095, 0, 255);
  
  if(bendReading < 250 && ledBrightness < 100){
      tone(buzzerPin, 1000, 500);
      delay(500);
  }else{
      if(bendReading < 250){
          analogWrite(ledPin, 255);
          delay(1500);
          analogWrite(ledPin, 0);
          delay(500);
      }else{
          if(ledBrightness < 100){
              analogWrite(ledPin, 255);
              delay(500);
              analogWrite(ledPin, 0);
              delay(1500);
          }
      }
  }

  delay(100);
}
Click to Expand
0

Reflection

In this project, the application of a bend sensor is notably intriguing and promising, as it offers considerable potential for interaction with people.

x
Share this Project

This project is unlisted and only folks with the link can see it. Be considerate and think twice before sharing.


Courses

48-675 Designing for the Internet of Things

· 11 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

~