User Tools

Site Tools


ingenuity_2019_misting_zone

This is an old revision of the document!


Area: 15×15? square filled with rubber chips with a couple of layers of rubber mat/plastic sheet underneath

Misters: one on each corner? (UNLESS SOMEONE WANTS TO DESIGN SOMETHING FANCIER THIS IS WHAT YOU GET)

 

Quick Mashup of an Adafruit DotStar strip with an IR distance sensor

// Simple strand test for Adafruit Dot Star RGB LED strip.
// This is a basic diagnostic tool, NOT a graphics demo...helps confirm
// correct wiring and tests each pixel's ability to display red, green
// and blue and to forward data down the line.  By limiting the number
// and color of LEDs, it's reasonably safe to power a couple meters off
// the Arduino's 5V pin.  DON'T try that with other code!
 
#include <Adafruit_DotStar.h>
// Because conditional #includes don't work w/Arduino sketches...
#include <SPI.h>         // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET
//#include <avr/power.h> // ENABLE THIS LINE FOR GEMMA OR TRINKET
 
#define NUMPIXELS 240 // Number of LEDs in strip
 
// Here's how to control the LEDs from any two pins:
#define DATAPIN    11
#define CLOCKPIN   13
//Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
// The last parameter is optional -- this is the color data order of the
// DotStar strip, which has changed over time in different production runs.
// Your code just uses R,G,B colors, the library then reassigns as needed.
// Default is DOTSTAR_BRG, so change this if you have an earlier strip.
 
// Hardware SPI is a little faster, but must be wired to specific pins
// (Arduino Uno = pin 11 for data, 13 for clock, other boards are different).
Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);
 
int sensorpin=0;
int val = 0;
int sensIdx = 0;
 
void setup() {
 
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
  clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
 
  strip.begin(); // Initialize pins for output
  strip.show();  // Turn all LEDs off ASAP
  Serial.begin (115200);
  randomSeed(analogRead(sensorpin));
}
 
// Runs 10 LEDs at a time along strip, cycling through red, green and blue.
// This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel.
 
int      head  = 0, tail = -10; // Index of first 'on' and 'off' pixels
uint32_t color = 0xFF0000;      // 'On' color (starts red)
 
void loop() {
  if (sensIdx>400){
    val=analogRead(sensorpin);
    sensIdx=0;
  }
  strip.setPixelColor(head, color); // 'On' pixel at head
  strip.setPixelColor(tail, 0);     // 'Off' pixel at tail
  strip.show();                     // Refresh strip
  delay(map(val,20,700,1,16)); // Pause 20 milliseconds (~50 FPS)
  Serial.println(val);
  sensIdx++;
 
  if(++head >= NUMPIXELS) {         // Increment head index.  Off end of strip?
    head = 0;                       //  Yes, reset head index to start
  //  if((color >>= map(val,20,700,1,16)) == 0)          //  Next color (R->G->B) ... past blue now?
  //    color = 0xFF0000;             //   Yes, reset to red
  //int numColor = map(val,20,700,0,16777215);
 
  int numColor = random(0,16777215);
  color=numColor;
  }
  if(++tail >= NUMPIXELS) tail = 0; // Increment, reset tail index
}
ingenuity_2019_misting_zone.1566320285.txt.gz · Last modified: 2019/08/20 12:58 by sdh7