Hulp bij Trap sketch wijzigen

Projecten die niet passen in bovenstaande onderwerpen
Berichten: 4
Geregistreerd: 16 Feb 2018, 12:20

Hulp bij Trap sketch wijzigen

Berichtdoor nicowater » 16 Feb 2018, 14:57

Hallo

Arduio uno
leds WS2812B

en geheel nieuw met arduino maar wel leuk om mee te spelen
ik ben bezig met trap verlichting
heb al gezocht op het forum en vond die van Maurice vergelijkbaar met die sketch die ik heb

nu wil ik hem veranderen naar 14 treden en 8 led,s per trede
heb nu de test met 4 leds per trede krijg hem niet werkend.Ik denk omdat de pir er nog niet is
als ik die tijdelijk uit kan schakelen zou dit mooi zijn

heb nu 60 leds komen er meer aan
LDR heb ik nog niet pir ook niet zijn besteld

alvast bedankt

[code][

/// Edit by Serge Niko June 2015

#include <Adafruit_NeoPixel.h>

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.

// Set up Variables
unsigned long timeOut=60000; // timestamp to remember when the PIR was triggered.
int downUp = 0; // variable to rememer the direction of travel up or down the stairs
int alarmPinTop = 10; // PIR at the top of the stairs
int alarmPinBottom =11; // PIR at the bottom of the stairs
int alarmValueTop = LOW; // Variable to hold the PIR status
int alarmValueBottom = LOW; // Variable to hold the PIR status
int ledPin = 13; // LED on the arduino board flashes when PIR activated
int LDRSensor = A0; // Light dependant resistor
int LDRValue = 0; // Variable to hold the LDR value
int colourArray[350]; // An array to hold RGB values
int change = 1; // used in 'breathing' the LED's
int breathe = 0; // used in 'breathing' the LED's


void setup() {
strip.begin();
strip.setBrightness(40); //adjust brightness here
strip.show(); // Initialize all pixels to 'off'
Serial.begin (9600); // only requred for debugging
pinMode(ledPin, OUTPUT); // initilise the onboard pin 13 LED as an indicator
pinMode(alarmPinTop, INPUT_PULLUP); // for PIR at top of stairs initialise the input pin and use the internal restistor
pinMode(alarmPinBottom, INPUT_PULLUP); // for PIR at bottom of stairs initialise the input pin and use the internal restistor
delay (2000); // it takes the sensor 2 seconds to scan the area around it before it can
//detect infrared presence.

}

void loop() {

if (timeOut+15700 < millis()) { // idle state - 'breathe' the top and bottom LED to show program is looping
uint32_t blue = (0, 0, breathe);
breathe = breathe + change;
strip.setPixelColor(0, blue);
strip.setPixelColor(3, blue);
strip.setPixelColor(7, blue);
strip.setPixelColor(10, blue);
strip.setPixelColor(11, blue);
strip.setPixelColor(14, blue);
strip.setPixelColor(15, blue);
strip.setPixelColor(18, blue);
strip.setPixelColor(19, blue);
strip.setPixelColor(22, blue);
strip.setPixelColor(23, blue);
strip.setPixelColor(26, blue);
strip.setPixelColor(27, blue);
strip.setPixelColor(30, blue);
strip.setPixelColor(31, blue);
strip.setPixelColor(34, blue);
strip.setPixelColor(35, blue);
strip.setPixelColor(38, blue);
strip.setPixelColor(39, blue);
strip.setPixelColor(42, blue);
strip.setPixelColor(43, blue);
strip.setPixelColor(46, blue);
strip.setPixelColor(47, blue);
strip.setPixelColor(50, blue);
strip.setPixelColor(51, blue);
strip.setPixelColor(54, blue);
strip.setPixelColor(55, blue);
strip.setPixelColor(58, blue);
strip.setPixelColor(59, blue);
strip.show();
if (breathe == 100 || breathe == 0) change = -change; // breathe the LED from 0 = off to 100 = fairly bright
if (breathe == 100 || breathe == 0); delay (100); // Pause at beginning and end of each breath
delay(10);


}

alarmValueTop = digitalRead(alarmPinTop); // Constantly poll the PIR at the top of the stairs
//Serial.println(alarmPinTop);
alarmValueBottom = digitalRead(alarmPinBottom); // Constantly poll the PIR at the bottom of the stairs
//Serial.println(alarmPinBottom);

if (alarmValueTop == HIGH && downUp != 2) { // the 2nd term allows timeOut to be contantly reset if one lingers at the top of the stairs before decending but will not allow the bottom PIR to reset timeOut as you decend past it.
timeOut=millis(); // Timestamp when the PIR is triggered. The LED cycle wil then start.
downUp = 1;
//clearStrip();
topdown(); // lights up the strip from top down
}

if (alarmValueBottom == HIGH && downUp != 1) { // the 2nd term allows timeOut to be contantly reset if one lingers at the bottom of the stairs before decending but will not allow the top PIR to reset timeOut as you decend past it.
timeOut=millis(); // Timestamp when the PIR is triggered. The LED cycle wil then start.
downUp = 2;
//clearStrip();
bottomup(); // lights up the strip from bottom up
}

if (timeOut+10000 < millis() && timeOut+15000 < millis()) { //switch off LED's in the direction of travel.
if (downUp == 1) {
colourWipeDown(strip.Color(0, 0, 0), 100); // Off
}
if (downUp == 2) {
colourWipeUp(strip.Color(0, 0, 0), 100); // Off
}
downUp = 0;

}



}

void topdown() {
Serial.println ("detected top"); // Helpful debug message
colourWipeDown(strip.Color(255, 255, 250), 25 ); // Warm White
//for(int i=0; i<3; i++) { // Helpful debug indication flashes led on Arduino board twice
//digitalWrite(ledPin,HIGH);
//delay(200);
//digitalWrite(ledPin,LOW);
//delay(200);
//}
}



void bottomup() {
Serial.println ("detected bottom"); // Helpful debug message
colourWipeUp(strip.Color(255, 255, 250), 25); // Warm White
//for(int i=0; i<3; i++) { // Helpful debug indication flashes led on Arduino board twice
//digitalWrite(ledPin,HIGH);
//delay(200);
//digitalWrite(ledPin,LOW);
//delay(200);
//}
}

// Fade light each step strip
void colourWipeDown(uint32_t c, uint16_t wait) {

for (uint16_t j = 0; j < 15; j++){
int start = strip.numPixels()/15 *j;
Serial.println(j);

for (uint16_t i = start; i < start + 35; i++){
strip.setPixelColor(i, c);
}
strip.show();
delay(wait);
}

}


void clearStrip(){
for (int l=0; l<strip.numPixels(); l++){
strip.setPixelColor(l, (0,0,0));
}

}
// Fade light each step strip
void colourWipeUp(uint32_t c, uint16_t wait) {
for (uint16_t j = 15; j > 0; j--){
int start = strip.numPixels()/15 *j;
Serial.println(j);
//start = start-1;
for (uint16_t i = start; i > start - 35; i--){
strip.setPixelColor(i-1, c);
}
strip.show();
delay(wait);
}

}



code]

Advertisement


Berichten: 4
Geregistreerd: 16 Feb 2018, 12:20

Re: Hulp bij Trap sketch wijzigen

Berichtdoor nicowater » 19 Feb 2018, 00:05




bedankt voor de hulp is al geregeld

Berichten: 1
Geregistreerd: 02 Jul 2013, 15:43

Re: Hulp bij Trap sketch wijzigen

Berichtdoor ps2-ghost » 25 Jun 2018, 16:15

Nicowater,

Ik ben nieuw met arduino en wil deze schakeling ook gebruiken, ik het 12 treden met 11 leds per trede.
Kan je mij helpen waar ik dit moet aanpassen, aangezien het jou al gelukt is.
Of als het kan jou sketch sturen zodat ik hem kan vergelijken.

Groeten Ton

Berichten: 3
Geregistreerd: 05 Jan 2019, 02:01

Re: Hulp bij Trap sketch wijzigen

Berichtdoor kolk123 » 05 Jan 2019, 02:45

is het jou al gelukt ps2? ik heb het zelfde probleem maar dan 16 tredes. enkel als ik meer al 548 led ingeef werkt niks meer. ik heb namelijk 576 leds.
als ik een test bestand met bijv kleuren probeer is wel alles werkend

Terug naar Overige projecten

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 9 gasten