# DailyDevice – Speedometer – IR_Rotary_Sensor

My daily device is a Speedometer that measures the number of times a wheel turns over time.

I wanted to figure out the relationship between the rotations per minute (rpm) of a DC motor with the amount of PWM voltage (controlled via transistor) and this method worked out.

To figure out the motor and transistor I used Marcello’s Daily Device (DC motor and potentiometer)

Parts for this Setup

– Potentiometer (to control wheel speed)

– Transistor + DC motor + SpokesWheel on axle (to measure amount of rotation)

– IR Rotary Sensor

IR Rotary Sensors

I bought an IR Sensor rotary kit from Creatron to do this. See the below link to see the sensors. It is basically an IR emitter and sensor put adjacent to each other. When the sensor is looping, it returns zeros when the sensor detects a signal from the emitter, and returns ones when the sensor is interrupted.

http://www.tinyosshop.com/index.php?route=product/product&product_id=541

The IR sensor can therefore detect whether it is being interrupted by the spokes of a turning wheel. By sampling the 0s and 1s over a set period of time, and determining the geometry of the spokes and wheels (e.g., 20 spokes per one rotation of wheel) one can calculate the amount that the wheel has turned over a set period of time. This value can then be converted into rotations per minute, which can be then converted into speed (speed = distance / time) by calculating the circumference of wheel.

Visuals of Setup and Demo

Overview

IR Sensor + DC motor with black spokes wheel connected to transistor + Potentiometer

IR Sensor – 3 Pins: 5Vs, Ground, and Digital output

Clearer image of spokes wheel

Video Demo

Serial.print values shows Potentiometer, DC voltage, digital IR value, # of rotations per sample interval (1 second), rotations per minute (RPM)

Code

// Function to use IR sensor to measure speed of turning spokes-wheel

// Motor and Potentiometer Values
int potPin = A4; int potValue = 0;
int motorPin = 3; int motorValue = 0;

// Rotary Wheel-Spin Sensor Values
int sensorRotaryPin = A0;
int sensorVal = 0; // 0 or 1 depending on whether the IR sensor detects the spokes or passes through them
int previousSensorVal = 0; // previous 0/1 value to use during loop calculations
int count = 0; // used for counting times digital signal shifts btw 0 and 1
float revolutions = 0; // number of times the wheel has turned 360 degrees
float rpm = 0; // rotations per minute
float speedVal = 0; // distance/time val calculated using revolutions and constants
int samplingInterval = 1000; // sample period of wheel turns over milliseconds to determine speed
long previousMillis = 0;

// Setup and Loop
void setup() {
Serial.begin(250000);
pinMode(8, INPUT);
}

void loop() {
potValue = analogRead(potPin); constrain(potValue, 0, 1023); // if(potValue>1023) {potValue=1023;}
motorValue = map(potValue, 0, 1023, 0, 255); analogWrite(motorPin, motorValue);
spokesCounter();
GetSpeed();

// Serial Value Printing
Serial.print(potValue); Serial.print(” “);
Serial.print(motorValue); Serial.print(” “);
Serial.print(sensorVal); Serial.print(” “);
Serial.print(count); Serial.print(” “);
Serial.print(revolutions); Serial.print(” “);
Serial.println(rpm);
}

// Functions
int spokesCounter() { // Counts the number of times that analogRead changes values. A count of 20 spokes is 360 degrees.
if (sensorVal != previousSensorVal) {
count++;
}
previousSensorVal = sensorVal; // sets previous sensor val for next iteration through loop to compare
}

float GetSpeed() {
if(millis() – previousMillis >= samplingInterval) { // uses timer to turn count() value into rotation values and speed data
revolutions = (count/2.0)/20.; // # of revolutions. 20 spokes. count value divided by 2 so each change between 0/1 counts as 1 spoke. If 20 changes then the wheel has gone around 360 degree and revolutions = 1
rpm = revolutions * (60000.0/samplingInterval); // revolutions per minute (60,000 ms)
speedVal = (rpm * 20.0); // 20 cm is the wheel’s circumference. speed = cm/minute
previousMillis = millis(); // reset timer to resample
count = 0; // reset counter for next sample
}
}

# Research Project: Volume by United Visual Artist

United Visual Artists (UVA) was founded in 2003 in London, UK by Matthew Clark, Chris Bird, and Ash Nehru. Originally, the 3 came together to create lighting and visuals for a concert for a London based music group called Massive Attack. Since then, they have showcased their work through many exhibitions and galleries and have won many awards. The group has been featured in multiple publications winning award after award for their creative approach in combining architecture, live-performances, installations, sculptors, and technology.

UVA has done work in Russia, UK, Australia, Hong Kong, Paris, and other cities across the globe. Apart from working with lasers, radars, and scanners, UVA also lectures across the globe. They tour around different universities and have even reached Toronto to speak to students at both Ryerson University And OCAD University in September of 2011.

Volume

As described on UVA’s site:

“UVA’s large-scale installation Volume first appeared in the garden of London’s V&A museum in 2006 and has since traveled as far as Hong Kong, Taiwan, St. Petersburg and Melbourne.

It consists of a field of 48 luminous, sound-emitting columns that respond to movement. Visitors weave a path through the sculpture, creating their own unique journey in light and music.

The result of a collaboration with Massive Attack, Volume won the D&AD Yellow Pencil in 2007 for Outstanding Achievement in the Digital Installation category.”

Inspiration:

The inspiration for volume was both the Play Station brief, which was to engage people in an emotional experience for the launch of PS3 in UK and Monolith, which is an installation displayed by UVA at John Madejski garden on Onedotzero’s transvision night. Monolith emits soothing colours and you hear calming sounds when no one is near. As people approach, the colours and sounds become louder and harsher, forcing people to step back to find their comfort zone. Monolith wasn’t entirely successful from an interaction point of view. It had more people than anticipated, so it spent too much time in ‘overload’ mode. But it did ‘work’ in that it created a powerful aura and transformed the space.

3 interaction layers

Model Overview

Technical Overview

To create Volume, UVA would have used their proprietary software and hardware called D3. D3 allows artists to control many different pieces of hardware and tools for installations, performances and other visuals. In the case of Volume D3 is controlling 48 LED towers, infrared cameras and 48 individual speakers located in each of the LED towers.

The D3 software has the capability for Real Time Simulation, Projector Simulation, Sequencing, Content Mapping, Playback, Configuring Output, d3Net, Show Integration, and Backup & Support. To run the software efficiently D3 also offers specifically built hardware for running their software.

As mentioned above D3 does Real Time Simulations of the art work. Here’s a screenshot of one of the available simulations for Volume. You can see that there is a timeline for the different events and interactions as well as a digital representation for each of the 48 LED towers.

For motion tracking of the experience we suspect that they are using some sort of IR areal grid system similar to this illustration found on the Panasonic website. This method would allow participants location to be tracked and monitored relatively simply as well as keeping down cost by by minimizing the number of IR cameras required in the installation.

The audio for Volume was written by Massive Attack since UVA has had an existing relationship with the band. The sound artist Simon Hendry has also worked on additional effects for multiple iterations of the installation. The connection between the D3 software and hardware and the installation is done with MIDI (Musical Instrument Digital Interface) controls connecting with the Music production software Logic Pro.

Prototype

To prototype the Volume installation we went through multiple iterations. The first iteration we were trying out a 8X8 RGB LED matrix and a MAX7219 LED driver chip.

We got it up and running but were unable to control individual LEDs or get unique colours displaying. So instead we switched to the 74HC595 chip for bit shifting the control output from the Arduino to allow one three pins control 8 LED’s per chip. Each chip can be connected, and daisy-chained to another chip which can control another 8 LEDs.

There is a lot of wiring but it is a good way for communicating with multiple LEDs and still keep open some pins on the Arduino for other sensors.

For the user motion and location detection we are using the Sonar sensor, for the audio we are using the Arduino Library called Mozzi and we are using a small speaker with a simple connection to the Arduino.

Schematic

Prototype Video

Final Video

Github Source Files

Github source for the master Arduino that runs the LEDs and sensor.

# Daily Device Workshop: (the unstoppable) Vibrator

My daily device creation is the handy vibrator. (Unfortunately, it won’t stop unless I hold the button down since the wiring is inverted).

To make the vibrating action, I used the motor in our toolkit, linked the wiring to the nodes on the button and linked those same wires to a power source (9volt battery). The linked and taped power section was then inserted in to a window cleaner roll.

(accidentally bought red playdough, so its a red vibrator now!)

# Bird – RGB lights mapped to Sonar

I put the RGB LED into the bird and controlled its colour output using the incoming Sonar values. The Sonar values were also translated mapped onto tone values played through a speaker.

Each of three RGB pins for the common anode LED were given mapped values between 0-255. The ratio of RGB values was correlated with distance values (0-20 cm) obtained by the Sonar distance sensor. (See code below for how the ratio of values were mapped and calculated).

Here’s a couple images of my wiring

Below is the CODE I used if you wanna see how I controlled the RGB LED and mapped the sounds, distance, colours onto each other.
// For RGB LED
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
int micPin = 0;
int micVal = 0;
int sampleRate = 500;
long lastChange = 0;

// For Ping Sensor
#include <NewPing.h>
#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 40 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

// For Speaker Output
#include <NewTone.h>
#define TONE_PIN 8
int speakerRate = 1000;
int minFreq = 250; // minimum and maximum frequencies
int maxFreq = 2000;

/*uncomment this line if using a Common Anode LED */
#define COMMON_ANODE

void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

Serial.begin(115200);
}

void loop() {
// PING
delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
Serial.print(“Ping: “);
int distance = uS / US_ROUNDTRIP_CM;
Serial.print(distance); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println(“cm”);

int distanceScaled = map(distance, 0, MAX_DISTANCE, 0, 100); // Normalize ping distance values

// RGB Values calculated from distanceScaled
int red = getRed(distanceScaled);
int green = getGreen(distanceScaled);
int blue = getBlue(distanceScaled);

// Output Tone
if(distanceScaled > 0) {
int freq = map(distanceScaled, 0, 100, 1500, 250);
NewTone(TONE_PIN, freq);
delay(1);
noNewTone(TONE_PIN);
}

if((millis()-lastChange>=speakerRate) && (distanceScaled > 0)) {
int freq = map(distanceScaled, 0, 100, maxFreq, minFreq);
NewTone(TONE_PIN, freq);
delay(5);
noNewTone(TONE_PIN);
lastChange=millis();
}

setColor(blue,red,green); // red delay(1000);
}

void setColor(int red, int green, int blue) {
#ifdef COMMON_ANODE
red = 255 – red;
green = 255 – green;
blue = 255 – blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}

int getRed(int distance) {
if((distance > 0) && (distance < 26)) {
int red = map(distance, 1,25, 0,255);
return red;
}
else if((distance > 25) && (distance < 51)) {
int red = map(distance, 26, 50, 255, 0); return red;
}
else{int red = 0; return red;}
}

int getGreen(int distance) {
if((distance > 25) && (distance < 51)) {
int green = map(distance, 25,50, 0,255);
return green;
}
else if((distance > 50) && (distance < 76)) {
int green = map(distance, 26, 50, 255, 0); return green;
}
else{int green = 0; return green;}
}

int getBlue(int distance) {
if((distance > 49) && (distance < 76)) {
int blue = map(distance, 50,75, 0,255);
return blue;
}
else if((distance > 75) && (distance < 101)) {
int blue = map(distance, 76, 100, 255, 0); return blue;
}
else{int blue = 0; return blue;}
}

# DAILY DEVICES: Camera Autofocus Working With Servo Motor

The project started with exploring varies parts used in camera lens and discovered that the whole mechanism was based on servo motors and gears. The process of focusing focal length is done with adjusting back and fourth the lens front and backward.

The working of servo motor is programmed with intelligent algorithmic approach which search for a perfect angle to get a perfect focus in auto mode.The components used in the project includes servo motor, arduino uno board and potentiometer.

CIRCUIT DIAGRAM

SKETCH

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 60; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                       // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                       // waits 15ms for the servo to reach the position
}
}

DEMO

# Daily Devices-Hand Dryer

I started with idea of washing machine having three aspects to it, water level, rinse & dry. But it was too complex to incorporate all the aspects in one. The next attempt was crane, but finally I built up a hand dryer.

A hand dryer is built with an IR sensor but I have used an ultrasonic sensor to trace the distance.  When a person is not within the vicinity, the hand dryer is in ‘Switch Off’ mode. A red led on the Hand Dryer indicates that. When you come near, the green led glows & the steady fan starts rotating. The voltage output of the green led & fan are connected to each other, which makes both of them work at the same time.

Circuit Diagram:

Sketch:

#define trigPin 13
#define echoPin 12
#define led 11
#define led2 10

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}

void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); – Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 15) { // This is where the LED On/Off happens
digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off
digitalWrite(led2,LOW);
}
else {
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
if (distance >= 200 || distance <= 0){
Serial.println(“Out of range”);
}
else {
Serial.print(distance);
Serial.println(” cm”);
}
delay(500);
}

# Digi Bird-Ready to Party!

I wanted to do a lot of things with my bird like flapping its feathers to whistle, engaging into a conversation, singing various songs on the intensity of the whistle blown, etc.

But with my little knowledge of this field, I managed to design a Party Bird. The bird loves to go for a party & is always ready for one with its funky glasses blinking to the rhythm of whistle & singing music.