#imIM Open Source Table Project
Initiated by Students, for Students
Supported by Kristy Kang, Galina Mihaleva and Poh Zhuang Yu
The Open Source Table Project aims to give students agency of equipment to students where they have the power to try out different sensors outside of class periods. This will allow them to take their technical education into their own hands. This also serves to allow students to pick and learn from a range of equipment first before committing to make their own purchase on equipment they require for the project.
The Open Source Culture should ensure that these communal equipment are taken care of by the students who use them and not taken away from this space for an obscure amount of time. Components are split up into individual categories for better access to equipment.
Guidelines:
1. All equipments are non-consumables unless stated otherwise. 2. Please return all equipment to respective spaces once you are finished with it. 3. Respect all equipment. If broken, please leave it in the BROKEN compartment on top of the cabinet.
All Code and Libraries for Sensor Station:
https://drive.google.com/file/d/17LXjfouaDeIQUMVmCP0_HMHR3xhiMzdT/view?usp=sharing
PHYSICAL BUTTONS
Momentary Push Button
2 Axis Joy Stick
const int xPin = A0;
const int yPin = A1;
const int swPin = 8;
void setup()
{
pinMode(swPin,INPUT);
digitalWrite(swPin, HIGH);
Serial.begin(9600);
}
void loop()
{
Serial.print("X: ");
Serial.print(analogRead(xPin),DEC);
Serial.print("|Y: ");
Serial.print(analogRead(yPin),DEC);
Serial.print("|Z: ");
Serial.println(digitalRead(swPin));
delay(500);
}
Tap Module
const int knockPin = 3; // the number of the knock sensor pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the knock sensor status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the knock sensor pin as an input:
pinMode(knockPin, INPUT);
}
void loop(){
// read the state of the knock sensor value:
buttonState = digitalRead(knockPin);
// check if the knock sensor is pressed.
// if it is, the knock sensor is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, LOW);
}
else {
// turn LED off:
digitalWrite(ledPin, HIGH);
}
}
Rotary Encoder
#define clkPin 2
#define dtPin 3
#define swPin 4 //the number of the button
int encoderVal = 0;
void setup()
{
pinMode(clkPin, INPUT);
pinMode(dtPin, INPUT);
pinMode(swPin, INPUT);
digitalWrite(swPin, HIGH);
Serial.begin(9600);
}
void loop()
{
int change = getEncoderTurn();
encoderVal = encoderVal + change;
if(digitalRead(swPin) == LOW)
{
encoderVal = 0;
}
Serial.println(encoderVal);
}
int getEncoderTurn(void)
{
static int oldA = HIGH;
static int oldB = HIGH;
int result = 0;
int newA = digitalRead(clkPin);
int newB = digitalRead(dtPin);
if (newA != oldA || newB != oldB)
{
// something has changed
if (oldA == HIGH && newA == LOW)
{
result = (oldB * 2 - 1);
}
}
oldA = newA;
oldB = newB;
return result;
}
SOUND BASED
Active Buzzer
int buzzer = 11;//the pin of the active buzzer
void setup()
{
pinMode(buzzer,OUTPUT);//initialize the buzzer pin as an output
}
void loop()
{
unsigned char i,j;
while(1)
{
//output an frequency
for(i=0;i<80;i++)
{
digitalWrite(buzzer,HIGH);
delay(1);//wait for 1ms
digitalWrite(buzzer,LOW);
delay(1);//wait for 1ms
}
//output another frequency
for(i=0;i<100;i++)
{
digitalWrite(buzzer,HIGH);
delay(2);//wait for 2ms
digitalWrite(buzzer,LOW);
delay(2);//wait for 2ms
}
}
}
Passive Buzzer
/*******************************************/
const int buzzerPin = 3;//the buzzer pin attach to
int fre;//set the variable to store the frequence value
/*******************************************/
void setup()
{
pinMode(buzzerPin,OUTPUT);
}
/*******************************************/
void loop()
{
for(int i = 200;i <= 800;i++) //frequence loop from 200 to 800
{
tone(3,i); //turn the buzzer on
delay(5); //wait for 5 milliseconds
}
delay(4000); //wait for 4 seconds on highest frequence
for(int i = 800;i >= 200;i--)//frequence loop from 800 downto 200
{
tone(3,i);
delay(10);
}
}
Small Sound
const int ledPin = 13;
const int soundPin = A0;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
int value = analogRead(soundPin);
Serial.println(value);
if(value > 25)
{
digitalWrite(ledPin,HIGH);
delay(20000);
}
else
{
digitalWrite(ledPin,LOW);
}
}
Big Sound
const int ledPin = 13; //the led attach to
const int soundPin = A0;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
int value = analogRead(soundPin);
Serial.println(value);
if(value > 30)
{
digitalWrite(ledPin,HIGH);
delay(200);
}
else
{
digitalWrite(ledPin,LOW);
}
}
ELECTRICAL
Relay Module
/**********************************************/
const int relayPin =6; //the "s" of relay module attach to
/**********************************************/
void setup()
{
pinMode(relayPin, OUTPUT); //initialize relay as an output
}
/***********************************************/
void loop()
{
digitalWrite(relayPin, HIGH); //Close the relay
delay(1000); //wait for 1 second
digitalWrite(relayPin, LOW); //disconnect the relay
delay(1000); //wait for 1 second
}
/*************************************************/
Breadboard
LIGHT BASED
Library: https://drive.google.com/file/d/1InATeJfOuvYSNhllXhI4bsDu8uzZFsMA/view?usp=sharing
IR Emission
#include <LiquidCrystal.h>
#include <IRremote.h>
IRsend irsend;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(5, 4, 9, 10, 11, 12);
const int ledPin = 13;
void setup()
{
pinMode(ledPin, OUTPUT);
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
}
void loop()
{
digitalWrite(ledPin, HIGH);
irsend.sendNEC(0xFFA25D, 32);
lcd.setCursor(0,0);
lcd.print("IRcode:");
lcd.setCursor(0,1);
lcd.print(" 0xFFA25D ");
delay(1000);
lcd.setCursor(0,1);
lcd.print(" ");
digitalWrite(ledPin, LOW);
delay(1000);
}
IR Receiver
#include <IRremote.h>
const int irReceiverPin = 2;
const int ledPin = 13;
IRrecv irrecv(irReceiverPin);
decode_results results;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop()
{
if (irrecv.decode(&results)) {
Serial.print("irCode: ");
Serial.print(results.value, HEX);
Serial.print(", bits: ");
Serial.println(results.bits);
irrecv.resume();
}
delay(600);
if(results.value == 0xFFA25D)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
IR Line Tracker
const int tracingPin = 8;
const int ledPin = 13;
void setup()
{
pinMode(tracingPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
int val = digitalRead(tracingPin);
if(val == HIGH)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
IR Obstacle
#define ledPin 13
#define avoidPin 8
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(avoidPin, INPUT);
}
void loop()
{
int avoidVal = digitalRead(avoidPin);
if(avoidVal == LOW)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
Photo Resistor
/*************************************************/
#include <LiquidCrystal.h>
const int photocellPin = A0;
const int ledPin = 13;
LiquidCrystal lcd(4, 5,9, 10, 11, 12);
int outputValue = 0;
/*************************************************/
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
}
/*************************************************/
void loop()
{
outputValue = analogRead(photocellPin);
lcd.setCursor(0, 0);
lcd.print("Photocell:");
lcd.setCursor(11, 0);
lcd.print(outputValue);//print the temperature on lcd1602
Serial.println(outputValue);
delay(1000);
lcd.setCursor(11, 0);
lcd.print(" ");
}
/*************************************************/
Photo Interruptor
/***************************************************/
const int ledPin = 13; //the number of the led pin
int val = 0; //variable to store the value from photo interrupter
/***************************************************/
void setup()
{
pinMode(ledPin,OUTPUT); //initialize led as an output
Serial.begin(9600);
}
/***************************************************/
void loop()
{
val = analogRead(0); //read the value from photo interrupter
Serial.println(val);
if(val > 400) //when interrupted
{
digitalWrite(ledPin,HIGH); //turn the led on
}
else
{
digitalWrite(ledPin,LOW); //turn the led off
}
}
/******************************************************/
ASSORTED SENSORS
Tilt Switch
const int buttonPin = 2; // the number of the tilt switch pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the tilt switch status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the tilt switch pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the tilt switch value:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Vibration Switchconst int vibswPin = 8; //the Vibration Switch attach to
const int ledPin = 13; //the led attach to
int val = 0; //initialize the variable val as 0
/******************************************/
void setup()
{
pinMode(vibswPin,INPUT); //initialize vibration switch as an input
pinMode(ledPin,OUTPUT); //initialize ledPin switch as an output
}
/*******************************************/
void loop()
{
val = digitalRead(vibswPin); //read the value from vibration switch
if(val == HIGH) //without vibration signal
{
digitalWrite(ledPin,LOW); //turn off the led
}
else
{
digitalWrite(ledPin,HIGH); //turn on the led
}
}
/*********************************************/
Flame Sensor
const int analogInPin = A0;
const int digitalInPin = 8;
const int ledPin = 13;
void setup()
{
pinMode(digitalInPin,INPUT);
pinMode(ledPin,OUTPUT);
}
void loop()
{
int analogVal = analogRead(analogInPin);
boolean stat = digitalRead(digitalInPin);
if(stat == HIGH)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
Touch Sensor
const int SensorPin=7;//电平输入端口
const int analogIn = A0;
const int ledPin = 13;
int SensorState=0;
int analogVal = 0;
void setup()
{
pinMode(SensorPin,INPUT);
pinMode(ledPin,OUTPUT);
}
void loop()
{
analogVal = analogRead(analogIn);
SensorState=digitalRead(SensorPin);
if(SensorState==HIGH)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
Heartbeat Sensor
#include "color.h"
#include "rgb.h"
#include "buzzer.h"
int band = 70;
void setup()
{
pinMode(8, OUTPUT);//the buzzer pin attach to
pinMode(9, OUTPUT);//the r pin of the RGB attach to
pinMode(10, OUTPUT);//the g pin of the RGB attach to
pinMode(11, OUTPUT);//the b pin of the RGB attach to
}
void loop()
{
int potVal = analogRead(A1);
int senVal = analogRead(A0);
if(senVal < potVal - band)
{
setColor(9, 10, 11, Blue);
}
else if(senVal > potVal + band)
{
setColor(9, 10, 11, Red);
beep(8);
}
else
{
setColor(9, 10, 11, Green);
}
}
ASSORTED WIRES(CONSUMABLES)
Male to Male
Male to Female
TEMPERATURE BASED
Library: https://drive.google.com/file/d/1RfMGJLYOX8-saKkqt68MJAoqZOIoaIOU/view?usp=sharing
Temp/Humidity
#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(5, 6, 9, 10, 11, 12);
dht DHT;
#define DHT11_PIN 4
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
// READ DATA
Serial.print("DHT11, \t");
//read the value returned from sensor
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
lcd.setCursor(0, 0);
lcd.print("Tem:");
lcd.print(DHT.temperature,1); //print the temperature on lcd
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Hum:");
lcd.print(DHT.humidity,1); //print the humidity on lcd
lcd.print(" %");
delay(200); //wait a while
}
Digital Temp DS18B20
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
LiquidCrystal lcd(4, 5,9, 10, 11, 12);
void setup(void)
{
lcd.begin(16, 2);
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
lcd.setCursor(0, 0);
lcd.print("Tem: ");
lcd.print(sensors.getTempCByIndex(0));//print the temperature on lcd1602
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Tem: ");
lcd.print(sensors.getTempCByIndex(0) + 273.15);//print the temperature on lcd1602
lcd.print(" F");
Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(sensors.getTempCByIndex(0)); //print the temperature on serial monitor
}
Digital Temp Thermistor
const int buttonPin = 7; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
//Serial.begin(9600);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
int val = analogRead(0);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Analog Temp Thermistor
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(4, 5, 9, 10, 11, 12);
#define analogPin A0 //the thermistor attach to
#define beta 4090 //the beta of the thermistor
#define resistance 10 //the value of the pull-down resistor
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
}
void loop()
{
//read thermistor value
long a =1023 - analogRead(analogPin);
//the calculating formula of temperature
float tempC = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
float tempF = tempC + 273.15;
// Print a message of "Temp: "to the LCD.
// set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print("Temp: ");
// Print a centigrade temperature to the LCD.
lcd.print(tempC);
// Print the unit of the centigrade temperature to the LCD.
lcd.print(" C");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
lcd.print("Fahr: ");
// Print a Fahrenheit temperature to the LCD.
lcd.print(tempF);
// Print the unit of the Fahrenheit temperature to the LCD.
lcd.print(" F");
delay(200); //wait for 100 milliseconds
}
MAGNETIC BASED
Reed Switch
const int analogInPin = A0;
const int digitalInPin = 8;
const int ledPin = 13;
void setup()
{
pinMode(digitalInPin,INPUT);
pinMode(ledPin,OUTPUT);
}
void loop()
{
int analogVal = analogRead(analogInPin);
boolean stat = digitalRead(digitalInPin);
if(stat == HIGH)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
Mini Reed Switch
const int ledPin = 13; // the number of the LED pin// variables will change:
int buttonState = 0; // variable for reading the pushbutton statusvoid setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the miniReed pin as an input:
pinMode(buttonPin, INPUT);
}void loop(){
// read the state of the mini reed :
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED off:
digitalWrite(ledPin, LOW);
}
else {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
}
Analog Hall
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensorvoid setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}void loop()
{
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
Serial.println(sensorValue, DEC);
}
Magnet Field Sensor
const int hallPin = 8; //the pin of hall sensor attach to
const int ledPin = 13; //the number of the led
int val = 0; //the variable to store the value read from hall sensor
/********************************/
void setup()
{
pinMode(hallPin,INPUT); //initialize the hall as an input
pinMode(ledPin,OUTPUT); //initialize the led as an output
}
/**********************************/
void loop()
{
val = digitalRead(hallPin); //read the value from hall sensor
if(val == HIGH)
{
digitalWrite(ledPin,LOW);
noTone(7);
}
if(val == LOW)
{
digitalWrite(ledPin,HIGH);
tone(7,320,500);
}
}
/*************************************/
Hall Magnetic Sensor
const int hallPin = 8; //the pin of hall sensor attach to
const int ledPin = 13; //the number of the led
int val = 0; //the variable to store the value read from hall sensor
/********************************/
void setup()
{
pinMode(hallPin,INPUT); //initialize the hall as an input
pinMode(ledPin,OUTPUT); //initialize the led as an output
}
/**********************************/
void loop()
{
val = digitalRead(hallPin); //read the value from hall sensor
if(val == HIGH)
{
digitalWrite(ledPin,LOW);
noTone(7);
}
if(val == LOW)
{
digitalWrite(ledPin,HIGH);
tone(7,320,500);
}
}
/*************************************/
ASSORTED LEDS
RGB LED + SMD RGB LED
/*************************************************************************/
const int redPin = 11; // R petal on RGB LED module connected to digital pin 11
const int greenPin = 10; // G petal on RGB LED module connected to digital pin 9
const int bluePin = 9; // B petal on RGB LED module connected to digital pin 10
/**************************************************************************/
void setup()
{
pinMode(redPin, OUTPUT); // sets the redPin to be an output
pinMode(greenPin, OUTPUT); // sets the greenPin to be an output
pinMode(bluePin, OUTPUT); // sets the bluePin to be an output
}
/***************************************************************************/
void loop() // run over and over again
{
// Basic colors:
color(255, 0, 0); // turn the RGB LED red
delay(1000); // delay for 1 second
color(0,255, 0); // turn the RGB LED green
delay(1000); // delay for 1 second
color(0, 0, 255); // turn the RGB LED blue
delay(1000); // delay for 1 second
// Example blended colors:
color(255,0,0); // turn the RGB LED red
delay(1000); // delay for 1 second
color(237,109,0); // turn the RGB LED orange
delay(1000); // delay for 1 second
color(255,215,0); // turn the RGB LED yellow
delay(1000); // delay for 1 second
color(0,255,0); // turn the RGB LED green
delay(1000); // delay for 1 second
color(0,0,255); // turn the RGB LED blue
delay(1000); // delay for 1 second
color(0,46,90); // turn the RGB LED indigo
delay(1000); // delay for 1 second
color(128,0,128); // turn the RGB LED purple
delay(1000); // delay for 1 second
}
/******************************************************/
void color (unsigned char red, unsigned char green, unsigned char blue) // the color generating function
{
analogWrite(redPin, red);
analogWrite(bluePin, blue);
analogWrite(greenPin, green);
}
/******************************************************/
3mm LED(Red & Green) / 5mm LED(Red & Green)
int redPin = 11; // select the pin for the red LED
int greenPin = 10; // select the pin for the blueLED
int val = 0;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
Serial.begin(9600);
}
/******************************************************/
void loop()
{
for(val=255; val>0; val--)
{
analogWrite(redPin, val);
analogWrite(greenPin, 255-val);
Serial.println(val, DEC);
delay(15);
}
for(val=0; val<255; val++)
{
analogWrite(redPin, val);
analogWrite(greenPin, 255-val);
Serial.println(val, DEC);
delay(15);
}
}
/********************************************************/
7 Colours Flash LED
LED Bulb(White)