Things used in this project

Hardware components:
SeeedStudio Digital RGB LED Strips of 2 meters
×5
SeeedStudio Seeeduino V4.2
×1
SeeedStudio Grove Ultrasonic Sensor
×2
Ojyc6a5jtrgslqwc5j7gw9ti
SeeedStudio Base Shield V2
×1
LED Logo projector
×1
SeeedStudio Breadboard Jumper Wire Pack
×1
twin-core cable of 8 meters
×1
5V power supply
×1
Software apps and online services:
Ide web
Arduino IDE
Hand tools and fabrication machines:
Hy gluegun
Hot glue gun (generic)
09507 01
Soldering iron (generic)

Code

HackTheStairs.inoArduino
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

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

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS   160

#include "Ultrasonic.h"

Ultrasonic ultrasonic(7);

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  
  Serial.begin(9600);
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

    long RangeInCentimeters;

 

    RangeInCentimeters = ultrasonic.MeasureInCentimeters(); // two measurements should keep an interval
    Serial.print(RangeInCentimeters);//0~400cm
    Serial.println(" cm");
    delay(1);

  if(RangeInCentimeters<150)
  {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,60,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(1); // Delay for a period of time (in milliseconds).

  }
  }

 if(RangeInCentimeters>150)
  {
     for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,0,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(1); // Delay for a period of time (in milliseconds).

  }
    }
}

Credits

24775161 518761985165296 7189132449178410453 n
Meilily Li
1 project • 1 follower
Love all things related to creativeness.
Contact
Thanks to Bill, Seeed Technical Support Team, Jiamou Yang, Seeed Technical Support Team, Danny, Workshop Manager at Seeed x.factory, and Violet Su, Community Manager at Seeed x.factory.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog