Hello guys, I'm a design student and totally new to this and very bad at coding for now. So my project is a lamp and it consists of 3 different length and different color neopixel strips, 3 same color single neopixel leds and a touch sensor. The sensor has to control everything: one touch turns on the strips, two touches turn on the single leds and a long touch turns everything off. I have a sort of working code, but it only turns on one strip and turns it off after a while, I need the leds to work until they are turned off. I hope my explanation is clear enough. I tried to do it by myself but it proved useless. I would be insanely thankful if you could help.
This is the code that I have:
#include <Adafruit_NeoPixel.h>
#define PIN 3
#define NUMPIXELS 22
int touch = 8;
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 50;
void setup() {
pixels.begin();
Serial.begin(9600);
pinMode(touch, INPUT);
#if defined(__AVR_ATtiny85__) && (F_CPU == 160000000000000)
clock_prescale_set(clock_div_1);
#endif
pixels.begin();
}
void loop() {
pixels.clear();
int touchValue = digitalRead(touch);
if (touchValue == HIGH){
Serial.println("touched");
for(int i=0; i<NUMPIXELS; i++) {
pixels.show();
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(200,0,95));
pixels.show();
delay(delayval);
}
}
}else{
Serial.println("not touched");
for(int i=0; i<NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
pixels.show();
}
}
delay(10);
}
Strip one is connected to pin 3 and has 22 leds
Strip two is connected to pin 5 and has 36 leds
Strip three is connected to pin 6 and has 53 leds
Single led one is connected to pin 9
Single led two is connected to pin 10
Single led three is connected to pin 11
The button is pin 8