Input Exploration: Sensors

Servo Mechanism Challenge

Tiandra Ray

To begin, we will take a look at different types of mechanisms for servos like this fun example of a paper robot fish. We will then look at the toolbox example to incorporate sensors that can activate the servo motors.

Prompt: You will each design and make any 2 of the mechanisms we went over today. They should be sketched out, prototyped using cardboard and other available materials.

While one can be a mechanical demonstration, the second prototype must incorporate a sensor as an input device such as an ultrasonic sensor. If your idea requires more than one servo or a different type of sensor, check with your coach first. Refer to the data sheets below this post to see available sensors.

Deliverables 

Create a blog post with a written description of your mechanisms as well as:

  • Documentation photos of your mechanisms in 2 + states (for example, open v. closed)
  • Create an animated GIF of your mechanisms in action

-https://gifmaker.me/

-https://ezgif.com/

PIR Motion Sensor

Liam Brady

PIR sensors (or passive infrared sensors) are motion sensors that measure subtle changes in infrared light in the room and register that change as movement. The processing is done on the chip and it outputs a current based on whether or not it detects motion.

int pin = 2;

void setup(){
  pinMode(pin, INPUT);

  pinMode(13, OUTPUT);
}

void loop(){
  int pirVal = digitalRead(pin);

  if (pirVal == 0) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }

  delay(100);
}

Infrared Distance Sensor

Liam Brady

Infrared distance sensors are sensors that measure how far away an object is by shooting infrared light at the object and measuring how much light is reflected back. They output an analog current which can be read by the Arduino.

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

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

  Serial.println(val);

  delay(100);
}

Force Sensor

Liam Brady

Force sensors are sensors that change resistance based on how much force is applied on it. The more force applied, the lower the resistance. Force can be measured using the analog pins on the Arduino.

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

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

  Serial.println(val);
}

Flex Sensor

Liam Brady

Flex sensors are resistance-based sensors that react to how much they get bent. The more they are bent, the larger the resistance across the sensor. The Arduino is able to measure the changing resistance to determine how much the sensor is bent.

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

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

  Serial.println(val);
  delay(100);
}

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);
}