Arduino LED+Force Sensor

Press to turn on the light
int sensorPin = A0;
int sensorValue;

//sensor value range: 0-1023
//200 is light touch
//500 is medium touch
//800 is hard touch
int limit = 200;


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 20

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
 Serial.begin(9600);
 pinMode(13, OUTPUT);


    #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
  #endif
  // END of Trinket-specific code.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}

void loop() {

 sensorValue = analogRead(sensorPin);
 Serial.print("Force Level: ");
 Serial.println(sensorValue);

 if (sensorValue > limit) {
 digitalWrite(13, HIGH);
 for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
 strip.setPixelColor(i, 125,0,125);         //  Set pixel's color (in RAM)
  strip.show();
 }
 }
 else {
 digitalWrite(13, LOW);
 strip.clear();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();
 }

 delay(100);
}
Press and light off
int sensorPin = A0;
int sensorValue;

//sensor value range: 0-1023
//200 is light touch
//500 is medium touch
//800 is hard touch
int limit = 200;


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 20

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
 Serial.begin(9600);
 pinMode(13, OUTPUT);


    #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
  #endif
  // END of Trinket-specific code.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}

void loop() {

 sensorValue = analogRead(sensorPin);
 Serial.print("Force Level: ");
 Serial.println(sensorValue);

 if (sensorValue > limit) {
 digitalWrite(13, HIGH);
 strip.clear();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();

 }
else {
 digitalWrite(13, LOW);
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
  strip.setPixelColor(i, 125,0,125);         //  Set pixel's color (in RAM)
  strip.show();

 }

 delay(100);
}
}

Arduino LED+ Distance sensor / PIR sensor

distance sensor + LED

Advantage: 相较于其他感应器,距离传感器可以捕捉它前方的物品和它之间的距离数据。因此我利用它捕捉观众和装置之间的距离,再通过coding根据距离数据调节LED亮度,亮度可以逐渐变化,变化速度可控。可以将“观众的手靠近该星球则该星球文明消失”这种交互关系,更形象地表达出来。

Disadvantage:感应器的感应区域小。手必须在感应器上方很小的范围内活动,才会被捕捉到信号;任何一些偏离,都会导致无法触发交互效果。所以,如果使用该感应器,为了保证关观众的交互体验感顺畅,则需要较多数量的该感应器。这又会带来一些电路连接上的复杂度。

#include <HCSR04.h>
// Initialize sensor that uses digital pins 13 and 12.
UltraSonicDistanceSensor distanceSensor(13, 12);

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 20

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup () {
    Serial.begin(9600);  //initialize serial connection so that we could print values from sensor.
    pinMode(13, OUTPUT);

    #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
  #endif
  // END of Trinket-specific code.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

}

void loop () {

    float distance = distanceSensor.measureDistanceCm();
    Serial.println(distance);
if (distance > 0) {
    if (distance < 30 ){
       digitalWrite(13, HIGH);
        for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
        strip.setPixelColor(i, 125,0,125);         //  Set pixel's color (in RAM)
         strip.show();
        }
      }else{
         digitalWrite(13, LOW);
         strip.clear();           // INITIALIZE NeoPixel strip object (REQUIRED)
         strip.show();
        }

  }
}

PIR +LED

Workshop: Intro to Creative Coding

· Part 1

https://www.creativeapplications.net/ 可以查看很多装置艺术作品,并且作者还会分享他们的coding。并且还可以在该网站找到相关工作。

https://cycling74.com/products/max 声音交互

https://puredata.info/ Pure Data(或称作PD)是米勒・帕克特在1990年代为创造交互的计算机音乐和多媒体作品而开发的视觉化程式设计语言。虽然帕克特是Pd的主要作者,但是它是一个多数开发者为起开发新扩展的开放源代码项目。

https://thecodingtrain.com/ coding教学网站

· Part 2

学习了p5.js, 和Processing好像。P5是处理语言的直接JS端口。 Processing.js是一个转换器,可以将纯处理代码即时转换为JS。 后者要求您学习处理,而不是JS,反之亦然。P5简短一些?不用下载可以直接在网页上使用,无处不在。

https://editor.p5js.org/ 编辑器

Reference

它有一个库,可以直接查询需要的代码:https://p5js.org/reference/ (在编辑器中 Help-Reference中也可以打开)

Final Outcome

· Part 3

The feasibility of the new idea was recognised by Micheal. Arduino was recommended and it was suggested to contact Physical Computing Specialist Technician Joanne for further technical support. The plan is to experiment with the Range Finder to control the LED lights and then to experiment with the 3D workshop materials to create the sphere.