Photoresistor

Liam Brady

Photoresistors are resistance-based sensors that react to how much light they are being hit by. The more light present, the smaller the resistance across the sensor. The Arduino is able to measure the changing resistance to determine how much light is in the room.

void setup() {
  Serial.begin(9600);
}

void loop() {
  int val = analogRead(A0);

  Serial.println(val);
}

Beyond the Tree

Hannah Glueck

Beyond the Tree


Hannah Glueck


Ultrasonic Sensor (Large)

Liam Brady

Ultrasonic sensors are distance sensors that use sound waves to detect how far away an object is. They send out high frequency bursts of sound and listen for its echo. They then determine how far away the object is based on how long it takes for the sound to return to the sensor. This variety requires an Arduino library to operate.

 

NewPing Library

#include <NewPing.h>

NewPing mysensor(5, 6, 200);

void setup() {
  Serial.begin(9600);
}

void loop() {
  int pingTime = mysensor.ping();

  int distance = mysensor.ping_in();

  int distance_cm = mysensor.ping_cm();

  Serial.println(distance);
}