Jasmine Pazer

Creative Developer

Arduino Projects


Ambient Connected House

This is a light blue bean+ project that uses the light sensor to detect the light in your room. There are two mini houses with two windows each. When your light is on, your window lights up, and when the room that the other house is in is on, their window lights up. This way you can know if your friend is home, and feel like you are in the same house from afar.

Documentation: http://bit.ly/2mHWhXx


Password Protected Door Alarm

If you don’t disarm it before you set off the ultrasonic sensor, it will sound an alarm and record your entry time.

fritzing_ppds

/* title: Password Protected Door Sensor
   date: 02/14/2016
   course: Physical Computing and Alternative Interfaces
   author: Jasmine Pazer
   email: jgp5980@rit.edu
*/

//import and initalize the lcd screen
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

//set pins
int potPin = A0;
int buttonPin = 13;
int piezoPin = 6;
int ultrasonicPin = A1;

//set password, and password holder
String passString = "";
String password = "12345";

//notes and frequencies for conversion for the piezo buzzer
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};

//button debounce variables
long lastDebounceTime = 0;
long debounceDelay = 50;
int currentButtonState;
int lastButtonValue = LOW;

//ultrasonic sensing variable
int lastUltrasonicValue = 0;
//number of times the alarm goes off
int alarmTimes = 10;
//number of times the alert has been triggered
int entranceAttempts = 0;
//the state the program is in
int state = 0;
//bool to keep a tone playing more than once
bool tonePlayed = false;

void setup() {
  /*description: setup, only runs once
    Variables used:
        buttonPin,
        piezoPin,
        ultrasonicPin,
        lastUltrasonicValue
    dependencies:
        none
    args: none
    returns: none
  */
  //start lcd
  lcd.begin(16, 2);
  //start Serial monitor
  Serial.begin(9600);
  //set pinModes
  pinMode(buttonPin, INPUT);
  pinMode(piezoPin, OUTPUT);
  //set the first reading of the ultrasonic sensor to compare off of.
  delay(100);
  lastUltrasonicValue = analogRead(ultrasonicPin);

}

int noteToFreq(char note) {
  /*description: to convert notes (char) into frequencies (int)
    variables used:
        names[],
        frequencies[]
     dependencies:
        none
     args: note (char)
     returns: (int)
  */
  //go through names looking for a match to note
  for (int i = 0; i < sizeof(names); i++)
  {
    if (names[i] == note)
    {
      //return the freq that is in the same spot the note was
      return (frequencies[i]);
    }
  }
  //return nothing if not a valid note
  return (0);
}

bool buttonPressed() {
  /*description: to determine if the button has been pressed.
    variables used:
        buttonPin,
        lastButtonValue,
        lastDebounceTime,
        debounceDelay,
        currentButtonState
    dependencies:
        none
    args: none
    returns: (bool)
  */
  //get buttonValue
  int buttonValue = digitalRead(buttonPin);

  //if it's not the same as lastButtonValue, start the timer
  if (buttonValue != lastButtonValue) {
    lastDebounceTime = millis();
  }

  //if the delay time has elapsed
  if ((millis() - lastDebounceTime) > debounceDelay) {
    //still not equal to last time?
    if (buttonValue != currentButtonState) {
      currentButtonState = buttonValue;
      //is it being pushed?
      if (currentButtonState == HIGH) {
        //return true
        return true;
      }
    }
  }
  lastButtonValue = buttonValue;
  //or return false
  return false;
}

bool ultrasonicTriggered() {
  /*description: to determine if the ultrasonic sensor has been triggered
    variables used:
        ultrasonicPin,
        lastUltrasonicValue,
        alarmTimes
    dependencies:
        none
    args: none
    returns: (bool)
  */
  int ultrasonicValue = analogRead(ultrasonicPin);

  if (abs(ultrasonicValue - lastUltrasonicValue) > 30)
  {
    alarmTimes = 10;
    return true;
  }
  return false;
}


void enterCode() {
  /*description: The state of the program where the password is entered
    variables used:
        potPin,
        piezoPin,
        passString,
        password,
        state,
        tonePlayed,
    dependencies:
        buttonPressed(),
        ultrasonicTriggered()
    args: none
    returns: none
  */
  //read the potentiometer value and convert it from pot numbers to 0-9
  int potValue = analogRead(potPin);
  int value = (int)map(potValue, 0, 1023, 0, 9);

  //if the button is pressed make a beep and add the number they chose to the password string they are building
  if (buttonPressed()) {
    tone(piezoPin, noteToFreq('g'), 100);
    delay(90);
    passString += value;
  }

  //time to print what they are doing on screen
  String printer;
  //print a '*' for all of the numbers they have already entered
  for (int i = 0; i < passString.length(); i++) {
    Serial.println(passString.length());
    printer += "*";
  }

  //display on screen
  lcd.setCursor(0, 0);
  lcd.print("Enter passcode:");
  lcd.setCursor(0, 1);
  //printing the '*' for what they've entered and showing the value for their next choice
  lcd.print(printer + value);

  //if they have entered the same number of characters as the original password
  if (passString.length() >= password.length()) {
    //clear the screen and move to the response sate
    lcd.clear();
    state = 1;
    //set it up to play the tone once
    tonePlayed = false;
  }

  //if someone enters before the password is submitted, the alarm goes off, and progress is deleted
  if (ultrasonicTriggered()) {
    passString = "";
    lcd.clear();
    state = 2;
  }
}

void response() {
  /*description: The state where the password is accepted or denied
    variables used:
        piezoPin,
        passString,
        password,
        state,
        tonePlayed,
    dependencies:
        buttonPressed(),
        ultrasonicTriggered(),
        noteToFreq()
    args: none
    returns: none
  */
  //if they entered the correct password
  if (passString == password) {
    //give feedback that it was correct
    lcd.setCursor(0, 0);
    lcd.print("Access Granted");
    lcd.setCursor(0, 1);
    lcd.print("Please Enter.");
    //play the you can enter tone once
    if (tonePlayed == false) {
      tone(piezoPin, noteToFreq('g'), 200);
      delay(200);
      tone(piezoPin, noteToFreq('C'), 500);
      tonePlayed = true;
    }
  } else { //if it was the wrong password
    //tell them it failed
    lcd.setCursor(0, 0);
    lcd.print("Access Denied.");
    //play the you can't enter tone once
    if (tonePlayed == false) {
      tone(piezoPin, noteToFreq('g'), 300);
      delay(300);
      tone(piezoPin, noteToFreq('d'), 500);
      tonePlayed = true;
    }
    //and if they push the button, they can try again
    if (buttonPressed()) {
      state = 0;
      passString = "";
      lcd.clear();
    }
  }

  //if the ultrasonic sensor is triggered
  if (ultrasonicTriggered()) {
    //and they had been accepted
    if (passString == password) {
      //send them back to the enter code screen and do not sound the alarm
      state = 0;
      delay(350);
      passString = "";
      lcd.clear();
    } else { //if they had been denied
      //sound the alarm!
      state = 2;
      passString = "";
      lcd.clear();
    }

  }
}

void alert() {
  /*description: The state where the alarm has been sounded
    variables used:
        piezoPin,
        state,
        entranceAttempts,
        alarmTimes,
        lastUltrasonicValue,
        ultrasonicPin
    dependencies:
        noteToFreq()
    args: none
    returns: none
  */
  //record the entrance attempt (or the actual entrance)
  entranceAttempts++;
  //display that an intruder has entered
  lcd.setCursor(0, 0);
  lcd.print("Intruder Alert");
  lcd.setCursor(0, 1);
  //and how many times the alarm has been triggered in the past
  lcd.print((String)entranceAttempts + " attempt/s");

  //play the alarm for a certain number of times
  while (alarmTimes > 0) {
    tone(piezoPin, noteToFreq('g'), 170);
    delay(170);
    tone(piezoPin, noteToFreq('d'), 170);
    delay(170);
    alarmTimes--;
  }
  //reset the ultrasonic sensor reading
  lastUltrasonicValue = analogRead(ultrasonicPin);
  lcd.clear();
  //go back to the enter code screen
  state = 0;
}

void loop() {
  /* description: loop, repeats for the entire program
   *  variables used:
        state
    dependencies:
        enterCode(),
        response(),
        alert()
    args: none
    returns: none
  */
  //call the appropriate function for each screen/state
  switch (state) {
    case 0://enter passcode
      enterCode();
      break;
    case 1://status accepted/denied
      response();
      break;
    case 2://sound alarm
      alert();
      break;
    default:
      break;
  }
}

Seeing Blind

A hat that lets the user see through the use of ultrasonic sensors and tiny vibration motors. The vibration motors will be against the user’s head and will vary in strength according to the distance of the user from objects. The ultimate goal will be for someone to be able to navigate around a space without the use of their eyes.

Sketch of project, and circuit.

It’s a mess…

Now I understand why the Arduino was such a breakthrough. Prototyping circuits quickly and neatly on an Arduino Uno and a breadboard are a walk in the park compared to fussing with soldering and stuff.

/* title: Seeing Blind - Hat (one half)
 date: 4/2/2016
 course: Physical Computing and Alternative Interfaces
 author: Jasmine Pazer
 email: jgp5980@rit.edu
*/

int ultrasonicPin = A1;
int vibratePin = 0;

void setup() 
{
 pinMode(vibratePin, OUTPUT);
}

void loop() 
{
 int ultrasonicValue = analogRead(ultrasonicPin);

 if (ultrasonicValue < 300) {
 int motorValue = map(ultrasonicValue, 300, 0, 0, 255);
 analogWrite(vibratePin, motorValue);
 }
 delay(10);
}

Electric Flute

For the audio project I decided to make an electric flute. I used a piezo vibration sensor, and 4 buttons for input and a small speaker for output. In order for sound to be made a button must be pressed and you must blow on the piezo sensor. Each button has a different pitch.

Picture: (coming soon)

/* title: Electric Flute
 date: 4/18/2016
 course: Physical Computing and Alternative Interfaces
 author: Jasmine Pazer
 email: jgp5980@rit.edu
*/

#include "pitches.h"

// these constants won't change:
const int ledPin = 10; // led connected to digital pin 13
const int vibePin = A3; // the amplifier output is connected to analog pin 0
const int speakerPin = 5;
const int button1 = 9;
const int button2 = 8;
const int button3 = 7;
const int button4 = 6;
int vibeTotal = 0;
int i = 0;

void setup() {
 pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
 Serial.begin(9600); // use the serial port

}

void loop() {
 // read the sensor and store it in the variable sensorReading:
 if (i < 10) {
   int vibeValue = analogRead(vibePin);
   int ledValue = map(vibeValue, 0, 1023, 0, 255);
   analogWrite(ledPin, ledValue);
   vibeTotal += vibeValue;
   i++;
 } else {
   if (vibeTotal / i > 0) {
     if (digitalRead(button1) == 1) {
        tone(speakerPin, NOTE_C3);
     } else if (digitalRead(button2) == 1) {
        tone(speakerPin, NOTE_D3);
     } else if (digitalRead(button3) == 1) {
        tone(speakerPin, NOTE_E3);
     } else if (digitalRead(button4) == 1) {
        tone(speakerPin, NOTE_F3);
     } else {
        noTone(speakerPin);
     }
  } else {
     noTone(speakerPin);
  }
  i = 0;
  vibeTotal = 0;
}
 delay(2); // Better for Processing showing data
}

——–pitches.h———

/*************************************************
 * Public Constants
 *************************************************/

#define NOTE_C3 131
#define NOTE_D3 147
#define NOTE_E3 165
#define NOTE_F3 175

Etch-a-Sketch

An Etch-a-Sketch made with C.H.I.P. (a full linux computer). This proect is written in processing using the Hardware I/O library. Processing is great, you can use classes unlike in Arduino. I thoroughly enjoyed being able to use classes again. 🙂

Picture: (coming soon)

/* title: Etch-a-Sketch on C.H.I.P.
 date: 5/15/2016
 course: Physical Computing and Alternative Interfaces
 author: Jasmine Pazer
 email: jgp5980@rit.edu
*/

import processing.io.*;

PVector pos, moveBy;

RotaryEncoder rot1;
RotaryEncoder rot2;

void setup()
{
 size(500, 500);
 rot1 = new RotaryEncoder(408, 409);
 rot2 = new RotaryEncoder(410, 411);

 pos = new PVector(width/2, height/2);
 strokeWeight(3);
}

void draw()
{
 rot1.update();
 rot2.update();
 moveBy = new PVector(rot1.Move, rot2.Move);
 
 line(pos.x, pos.y, pos.x + moveBy.x, pos.y + moveBy.y);
 pos.add(moveBy);

 println("pos: " + pos + " moveBy: " + moveBy); //print it out in the console
}

———–RotaryEncoder (class tab)————-

class RotaryEncoder {
 int CLK;
 int DT;
 int rotation; 
 int value;
 int Move;

 RotaryEncoder(int clk, int dt) {
 CLK = clk;
 DT = dt;
 GPIO.pinMode (CLK, GPIO.INPUT);
 GPIO.pinMode (DT, GPIO.INPUT);

 rotation = GPIO.digitalRead(CLK);
 }

void update() {
  Move = 0;
  value = GPIO.digitalRead(CLK);
  if (value != rotation) { // we use the DT pin to find out which way we turning.
    if (GPIO.digitalRead(DT) != value) { // Clockwise
      Move = 1;
    } else { //Counterclockwise
      Move = -1;
    }
  } 
  rotation = value;
 }
}

Next Post

Previous Post

© 2024 Jasmine Pazer