Potentiometer and GSR Sensor


I found the potentiometer pretty simple to work with. I connected one pin to power, the other to ground and the middle to analog pin Ao. I added the LED to the circuit and connected the anode to 330k resistor and to pin 9 and the cathode to ground.



















I used this code to light up the LED based on the position of the potentiometer. The maximum value for the potentiometer was the brightest value for the LED and vice versa.

int LEDpin = 9;
int potentiometerPin = 0;
int LEDvalue;
int potentiometerValue;

void setup(){
pinMode(LEDpin, OUTPUT);

void loop(){
  potentiometerValue = analogRead(potentiometerPin);
  LEDvalue = map(potentiometerValue, 0, 1023, 0, 255);
  analogWrite(LEDpin, LEDvalue);

GSR Sensor

Playing with sensors is one of the most fun things I have done this semester! Inspired by my wearable technology class, I started to look into the study of emotions and came across the Galvanic Skin Response Sensor. When people experience an arousing stimulus, our bodies generate a variety of psychophysical responses. One of those responses are micro-pulses of sweat that  increases the electrical conductance of the skin. This can be measured using the GSR sensor. I found a few companies who are manifacuring GSR sensors but really wanted to build one myself. I came across a pretty simple DIY tutorial online which i followed to make my own GSR sensor.


I soldered an 2 electrical wire to 2 penny coins. It wasn’t simple to solder to a coin but after a few tries I managed to make a solid connection.


Soldering Copper Coins







I connected one side of the sensor to power and the other side to a 10k resistor to ground and to pin A0. I connected an LED to pin 9.











I used this code to translate the sensor data to the brightness of the LED, so the higher the excitement the more bright the LED and the more calm the less bright it is.  I based my code on the fade code and sensor code. Since the GSR sensor reads a relaxed state for the value of 20, I set it up as the lowest threshold so if it’s the value is higher the LED with fade in (5 increments at a time) and if lower then fade out the same way.

int ledpin = 9;

int GSRPin = 0;

int LEDvalue;
int GSRValue;
int fadeValue=0;
int fadeAmount=5;
int brightness=0;
//int i=5;

void setup(){
  pinMode(ledpin, OUTPUT);

void loop(){
  GSRValue = analogRead(GSRPin);
 // LEDvalue = map(GSRValue, 20, 50, 0, 255);
  analogWrite(ledpin, LEDvalue);

     // fade in from min to max in increments of 5 points:
  //for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
    // sets the value (range from 0 to 255):
    brightness = brightness + fadeAmount;
    analogWrite(ledpin, fadeValue);   

    // wait for 30 milliseconds to see the dimming effect

    } else if (GSRValue <20){
     // fade out from max to min in increments of 5 points:
 // for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledpin, fadeValue);
 fadeAmount = -fadeAmount ;
    // wait for 30 milliseconds to see the dimming effect

Here is the result:

I find the GSR sensor fascinating! although it is probably not an accurate measurement there are so many interesting things one can do with it. For my wearable technology class I experimented with building an emotional meter neckless to measure how excited/ calm  someone is in any given movement. The GSR sensor is connected to a lilypad simple using a conductive thread. I hocked up an RGB LED light to it so it lights in different colours based on your emotional state. Here it is:

Emotional Meter- front

Emotional Meter- back

Metal snaps for modularity


Assignment 7 Smurfs welcome U!










Play with light sensor + LED+ speaker + arduino board


At first my idea is to build a door alarm when somebody broke into the house , it will alarm, then I build circuit with light sensor and buzzer ,

I bought a huge buzzer then . But I found the sound is quite annoying, personally I don’t like this boring design. Then I thought about use speaker,

we had a class to play with tone testing before, it was fun.

So I change my idea to do something using in the store to welcome people. When the client open the door, the sound of happy song will welcome them,

when the door is close, the smurf with LED smiley face will blink.










The light sensor will be placed to the door frame ,when the door is close ,

the door will prevent light coming to sensor, when the door is open ,the sensor will sense the light.







Build the circuit, a LED smiley face , the 6 light divide into 3 group ,

which are paralleled in the circuit. he other out put device is speaker,

the light senor is build as Jim showed us.

Then I print out the the smurf image,

then put smiley LED face into the his face ,

although it looks like this guy is bucktooth now ,

but it looks so cute when get further distance with LED lighting.


in the video, I turn on the flash of the camera ,so when the camera close to the sensor, the song will play. My room is dark ,the sensor is not sensitive enough.
Arduino Code
int potPin = A0;
int led = 8;
#include <Tone.h>Tone tone1;


int notes[] = { 0,

char *song = “Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#”;

void setup(void)
pinMode(led, OUTPUT);

#define isdigit(n) (n >= ‘0’ && n <= ‘9’)

void play_rtttl(char *p)
// Absolutely no error checking in here

byte default_dur = 4;
byte default_oct = 6;
int bpm = 63;
int num;
long wholenote;
long duration;
byte note;
byte scale;

// format: d=N,o=N,b=NNN:
// find the start (skip name, etc)

while(*p != ‘:’) p++;    // ignore name
p++;                     // skip ‘:’

// get default duration
if(*p == ‘d’)
p++; p++;              // skip “d=”
num = 0;
num = (num * 10) + (*p++ – ‘0’);
if(num > 0) default_dur = num;
p++;                   // skip comma

Serial.print(“ddur: “); Serial.println(default_dur, 10);

// get default octave
if(*p == ‘o’)
p++; p++;              // skip “o=”
num = *p++ – ‘0’;
if(num >= 3 && num <=7) default_oct = num;
p++;                   // skip comma

Serial.print(“doct: “); Serial.println(default_oct, 10);

// get BPM
if(*p == ‘b’)
p++; p++;              // skip “b=”
num = 0;
num = (num * 10) + (*p++ – ‘0’);
bpm = num;
p++;                   // skip colon

Serial.print(“bpm: “); Serial.println(bpm, 10);

// BPM usually expresses the number of quarter notes per minute
wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)

Serial.print(“wn: “); Serial.println(wholenote, 10);

// now begin note loop
// first, get note duration, if available
num = 0;
num = (num * 10) + (*p++ – ‘0’);

if(num) duration = wholenote / num;
else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after

// now get the note
note = 0;

case ‘c’:
note = 1;
case ‘d’:
note = 3;
case ‘e’:
note = 5;
case ‘f’:
note = 6;
case ‘g’:
note = 8;
case ‘a’:
note = 10;
case ‘b’:
note = 12;
case ‘p’:
note = 0;

// now, get optional ‘#’ sharp
if(*p == ‘#’)

// now, get optional ‘.’ dotted note
if(*p == ‘.’)
duration += duration/2;

// now, get scale
scale = *p – ‘0’;
scale = default_oct;


if(*p == ‘,’)
p++;       // skip comma for next note (or we may be at the end)

// now play the note

Serial.print(“Playing: “);
Serial.print(scale, 10); Serial.print(‘ ‘);
Serial.print(note, 10); Serial.print(” (“);
Serial.print(notes[(scale – 4) * 12 + note], 10);
Serial.print(“) “);
Serial.println(duration, 10);
tone1.play(notes[(scale – 4) * 12 + note]);
Serial.print(“Pausing: “);
Serial.println(duration, 10);

void loop(void)
{ int val = map(analogRead(potPin), 0, 1023, 0, 10);

else if(val>2){digitalWrite(led,LOW);



Assignment 7: Sensor (Photocell and Buzzer)

I used a photocell as control for the speed of pulses a buzzer creates. I mapped the incoming photocell values to a range that could then be used as the amount of delay between seting pin 7 HIGH and LOW (range was 50 millis to 300 millis). This allowed for adjusting the speed of pulses the buzzer generated.

Here is code for the arduino:

Here is an image of the circuit:

And video:


Assignment 7 – PWM

I enjoyed the analog lab. simple experiments that open up fantastic possibilities.


I chose to experiment with PWM, because I will be applying it in my final project.

Simply, I used a light sensor to switch in between two LEDs. Depending on the lighting conditions, one of two LEDs will pulse – each at it’s own rhythm.

here is the  video:  PWM with 2 LEDs (although it doesn’t seem like the video is loading)

so here are two pictures:















Assignment 7: Analog Lab

Using the potentiometer and photo resistor this time was a nice way gain control over elements like the LEDS and the buzzer. For me, however, it took a while to reach a point of satisfaction with my Arduino setup as some of my components were weak and needed constant readjusting…I should really solder some of the more fragile wiring.

I went through the analog lab and used the code provided in the blog and found that it was sufficient for using the Arduino circuit. I noticed that the LED did not gradually dim even though the values caught and displayed by the photo resistor , shown via the Serial Monitor, recognized the amount of light present.

Here are some photos of my progress with the analog lab:

Using the potentiometer to dim the LED light…I noticed it never fully turns off and I also doubt it was being lit to full capacity…ah, the mysteries of life.

Photo resistor in place of the potentiometer…some minimal rewiring. This set up was not producing the best results–it seemed to have a life of its own. Regardless, the Serial Monitor is quite useful, and I’m sure the changeable values would really be helpful to implement in a Processing sketch.

In my attempt to create an original piece, I wanted to use the photo resistor to manipulate the “Supper Light RGB” LED (yes, it does say Supper…maybe they wanted it to say Super? I don’t know) so that depending on your proximity to the photo resistor the LED would change colour….RED if you were close, GREEN if you were within a normal distance, and BLUE if the resistor was quite a distance away from you. The idea was to put the LED into a white balloon and allow it to emit the colour that indicated your physical proximity to the object, via the photo resistor of course–this is only valid given the assumption that as one comes closer to the object (photo resistor in this case) that their body would block out light more and more. The colour also indicates detection of warmth in this way…or at least that was the intention.

This plan failed to be executed because my “Supper” light died…I saw the RED light in the LED fuse out and then later one of the legs decided amputation was a good look. See the image below for some visual articulation:

I am excited, however, to dip back into Processing and blend that with Arduino…much fun!

Week 7: Potentiometer & Sensor

It was really fun to play with the potentiometer. For practicing, I built a simple circuit to control the buzzer sound using potentiometer. Below are the final work, the code I used and a short video of how the circuit works.

Using potentiometer to control alarm buzzer


The video Assignment7_LinhDo_Potentiometer

After experimenting the potentiometer, I moved on to the light sensor (or also called photocells?).  After hours of studying and experimenting (hah), I finally made the sensor works in controlling the brightness of the LED.  I want to make the LED light brighter in the dark and darker when it’s bright.

Circuit using photocells to control LED

Then I placed a hard paper in between the LED and the photocells to make sure the light from the LED doesn’t affect the light sensor.

Preparing a flash-lamp… 

… and experimenting in the dark! 

Hopefully you can see the brightness of the light changed based on the light the sensor detected (more light to sensor à less light in LED)

The video Assignment7_LinhDo_LightSensor

Light measurement

Below are the code and the diagram I used in this experiment, I made the diagram using fritzing from http://fritzing.org/download/ , which Kate showed us in class earlier.


When thinking about sensors and their applications, I was amazed to realize that there is so much we can do. For example, outdoors lighting. I always got problem with coming home at night and cannot find my key in the dark. Now, with an outdoor light using photocells we will always have enough light. Also, since my circuit was built to make the light automatically reduce or improve their brightness, it would be great to use in decoration (ex. Christmas trees) – you don’t need to worry about turning the decoration lights on and off anymore, they will come up and turn off naturally. I was thinking I should also add conditional statements on the code, making the light turn off when the analog light  reach 800 instead of making it shines low all the time. This function will help save lots of energy as well.

Also, I always wonder how the light that can detect motion works. In the house I lived before, I found it super interesting whenever there was motion in front of the door (people coming in and out of house, squirrel running by etc.), the light would automatically turn on. Now I kind of understand, the secret of it is something called motion detect sensor :D. Anyway, I accidently found this video on youtube, an example of Arduino motion detector that I guess, work the same with the motion detect light that has just been mentioned. However, instead of using light as the outcome, they use alarm and turn it into a security alarm (?).

It’s said to be built using Arduino, resistors, a buzzer, a led, some buttons and a PIR motion sensor module bought from here . Anyone wanna try to build it?

Eyes’ protection product

I am quite interested in the sensor, it could make a lot of funny effect.

I think a lot how could this sensor could be used in product design.

Then I think it could be used in a eyes’ protected design.

Working in poor light condition is harmful to people’s eyes. So I think it is good to have a product that show people how the light condition is.

I make the circuit like that..


when the light condition is good enough the red like will be turn on, else, the orange one would be turn on.

we could could change the light and make it in to a box , the box surface have two face like this


if the light condition is good the smile face will be turned on ,else, the cried face will be turn on.

Photoresistor and LED lights

Playing around with the sensors was satisfying this week. Few sensors idea

  • when someone yawns in class, the light turns off =)
  • sensors for water usage; if one uses too much water, sensor goes off and either warns the person or turns off the water.
  • meat and oven sensor: for christmas or thanksgiving cooking, where instead of checking turkey with a thermometer, one can have a sensor that detects the degree that the turkey is cooked.
  • flu detecter; a sensor that detects flu, so people can be more aware of who is sick!
  • sensors for smell on the plane’s washroom or public washroom; when the washroom stinks too much, you are notified and can avoid that particular stall or wait for few minute before going in to that stall.
  • sensors for sensors!

I was very interested in playing around wit the light levels and how they can initiate other effects. So I started testing with two lights with the photoresistor to see how different light levels can influence the LED lights. Here is the initial code


int OrangePin = 9;
int GreenPin = 10;
int potentiometerPin = 0;
int LEDvalue;
int potentiometerValue;

void setup(){
pinMode(OrangePin, OUTPUT);
pinMode(GreenPin, OUTPUT);

void loop(){
potentiometerValue = analogRead(potentiometerPin);
LEDvalue = map(potentiometerValue, 0, 1023, 0, 255);

if(potentiometerValue 0){
digitalWrite(OrangePin, HIGH);
} else {
digitalWrite(OrangePin, LOW);

if(potentiometerValue 300){
digitalWrite(GreenPin, HIGH);
} else {
digitalWrite(GreenPin, LOW);



I started with one orange and one green LED light, and set a range to inform when should the LED light to be turned on.


Afterward, I went back to the calibration exercise that Kate provided us, and try to understand better how calibration works, and started thinking about multiple lights influenced by the amount of sunlight.


What if I have a message that I want to deliver, and as the sun goes down, the message slowly appears? Thinking about it just made it more exciting. Due to the limited amount of LED lights that I have, and the amount of breadboard space and resistors, I can only illustrate an almost heart shaped figure.

DIGF 6B02 – Creation & Computation
by Cathy Chen

Sunlight and LED light
Real Version #2
Test Version #6

Reference: Arduino Calibration

Instructions: See how the amount of light that the potentiometer receieves affects the LED lights!

int potentiometerPin = A0;
int i = 0;
int myPins [] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int potentiometerValue = 0; // the sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value

void setup() {

while (millis() sensorMax) {
sensorMax = potentiometerValue;

if (potentiometerValue < sensorMin) {
sensorMin = potentiometerValue;


void loop() {

potentiometerValue = analogRead(potentiometerPin);
potentiometerValue = map(potentiometerValue, sensorMax, sensorMin, 0, 11);
potentiometerValue = constrain(potentiometerValue, 0, 11);

for(i = 0; i = pin-2){
analogWrite(pin, 255);
} else {
analogWrite(pin, 0);





Challenge this week:

After inserting all twelve LED lights, resistors and wires into the breadboard, and connect the wires to the arduino board, I tried to turn on all of them all at once with the photoresister. Undoubtedly, there were few lights that weren’t working properly. I had to look into the ones that didn’t work, to check if the wiring is right or is it the LED’s problem, is it the breadboard, or the wire. In a way, this resembles a debugging software task, where you try to rule out any possible affecting elements one by one. This process took me a while to finally have all twelve lights working.

In my case, three LED lights did not work, and the problems were:
1. the ground wire was broken
2. wrong wiring, thus wrong connection
3. the resistor was broken

Also photoresister sometime can’t detect the environment change very well

I tried to recap on how to do arrays and function and was a bit surprised in how much I needed to be reminded.

3 different light sensors…









This week I decided to try to understand the differences between 3 different light sensors.

1 – Photoresistor or LDR (Light Dependent Resistor)

2 – Ambient Light Sensor (TEMT6000)

3 – Light Intensity to Frequency IC (TSL230R)

I combined the code from the two bildr tutorials (TEMT6000 + TSL230R), then added some code to read the LDR, and got a simultaneous serial readout of the 3 sensors.

I am still assessing the ranges of the 3 sensors, but so far the Ambient Light Sensor is very sensitive; it takes a lot of direct light to get it to max out at 1023, whereas the photo resistor maxes out around 700 under the same light (both sensors are analog in nature). What’s interesting is that both the Ambient Sensor and the LDR show similar (+ or – 30) readings in low ambient light, but diverge greatly as intensity increases.

The Intensity to Frequency IC (integrated circuit) is completely different in the type of data it produces. Because it is an digital circuit (with 3 sensitivity levels) it produces very detailed readings (by varying the PWM frequency).

At first I thought I would be able to figure out the time of day based on the intensity of the light with these sensors (ideally creating a sensor that can identify “Magic Hour”), but I need to spend more time both researching frequency and spectrum wavelength (totally forgot that colour is measured by wavelength, not frequency… hence “Magic Hour”, with all of its wonderful colours, would be difficult to identify without one of these as well: Colour Light Sensor).


Along the way, I also thought of a use for a LDR… a bookmark, for all your pages… no more dog ears. When you open a book you’ve marked, the cell acts as a switch that signals your digital note-taking device of choice, to text you all the page and paragraph information (however you’ve formatted your notes) for each would-be dog-eared page…

The photo-sensor switch isn’t too difficult to build… but the rest… well… that’s the trick.

Light Sensors Code

// 3 Light Sensors for Readout
// Marc De Pape
// Creation and Computation
// OCAD University
// October 26 2011
// Based on:
// Part: http://www.sparkfun.com/products/8940
// Part: http://www.sparkfun.com/products/8688
// Reports the analog reading of the TEMT6000
// Article: http://bildr.org/2011/06/temt6000_arduino/
// Reports the frequency from the TSL230, higher number means brighter
// Article:  http://bildr.org/2011/08/tsl230r-arduino/ 

int TSL230_Pin = 4; //TSL230 output
int TSL230_s0 = 3; //TSL230 sensitivity setting 1
int TSL230_s1 = 2; //TSL230 sensitivity setting 2

int TSL230_samples = 5; //higher = slower but more stable and accurate

int temt6000Pin = A0; //TEMT6000 Ambient Light Sensor

int photoResistorPin = A2; //Photoresistor (LDR)

void setup(){

void loop(){

  float FREQUENCY = readTSL230(TSL230_samples); //Print Frequency IC reading
  Serial.print("  frequency");

  float LDR = readLDR(); //Print LDR Reading
  Serial.print("  LDR");

  float AMBIENT = readTEMT600(); //Print Ambient Reading
  Serial.print("  ambient");


void setupTSL230(){
  pinMode(TSL230_s0, OUTPUT);
  pinMode(TSL230_s1, OUTPUT); 

  //configure sensitivity - Can set to
  //S1 LOW  | S0 HIGH: low
  //S1 HIGH | S0 LOW:  med
  //S1 HIGH | S0 HIGH: high

  digitalWrite(TSL230_s1, LOW);
  digitalWrite(TSL230_s0, HIGH);

// READ Ambient Sensor
float readTEMT600(){
  float light = analogRead(temt6000Pin);
  return light;

// READ Photoresistor
float readLDR(){
  float light = analogRead(photoResistorPin);
  return light;

// READ Frequency IC
float readTSL230(int samples){
  //sample light, return reading in frequency
  //higher number means brighter

  float start = micros();
  int readings = 0;

  while(readings < samples){
    pulseIn(TSL230_Pin, HIGH);
    readings ++;

  float length = micros() - start;
  float freq = (1000000 / (length / samples)) * 10;

  return freq;

Emotional Frequency Sensor–well, a first step to the idea

This week, experimenting with new sensors for Arduino, I was really excited to bring my personal fascination with “magic” in my artwork—making the invisible, visible and expressing what the body (the nervous system, senses and body language) tries to communicate though a noticeable expression—into the realm of sensors. I kept thinking to myself what is the body trying to communicate that goes unseen, (the natural sensors [input and output]) which directs invisible messages or commands to the brain? I had two goals: make the invisible visible and express what our bodies communicate into a new context output—visual representation, data tracking, and demystified expressions that people outside of our physical body space can interpret.

After deconstructing (in my head) our bodies’ natural sensors input and output (eyes, skin/neurological system, touch, taste, scent, voice, spatial recognition, muscle memory, hearing) and their neurological and psychological purposes as well as thinking of the physics principle that all matter is in constant vibratory motion, while riding on the subway, a line from an Erykah Badu song popped into my head: “Our emotions have a vibratory frequency to them. There are only two emotions that humankind experience: fear and love. While other emotions branch either directly or indirectly from these two emotions. Fear has a long and slow frequency vibration to it, while love has a very rapid and high frequency.”  (I don’t know if her ideas have any merit to them, but I like what she’s suggesting.) This was exactly what I wanted to begin to pick up and represent through sensors. I was worried that I would need a much more sensitive and specific sensor than the simple vibration sensor I already had—maybe something like an EKG or EEG. I was right: the vibration sensor doe not cut it. But, at least it’s a good start.

My hope for this week’s assignment was to create (at a much later stage) a wearable vibratory sensor to track the emotional or physical vibrations of the people one encounters throughout a day. This would allow for each individual emotional vibration level to be captured, input, tracked, computed and visualized through Processing to finally create a visual piece that can be projected as an art installation representing all of the vibrations we encounter throughout a typical day.

Here is a video of the vibration sensor that I got working today: Vibration Video