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);
}
}
#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();
}
}
}
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.