Hello everyone,
I'm still quite new to Arduino and I'm trying to do small projects with the Arduino.
I'm working on a night light that when you pick up the light and touch the capacactive sensor the led strip lights up.
So far I managed to hook everything up so it works, but now the code...
I'm trying to combine 2 codes (one for the capacitive sensor and 1 for the LED strip) but I'm affraid I'm stuck.
Code for the LED strip:
#include <FastLED.h>
#define NUM_LEDS 7
#define LED_PIN 3
CRGB led [NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL,LED_PIN>(led, NUM_LEDS);
for (int i = 0; i < NUM_LEDS; i++){
led = CRGB (0, 0, 255);
}
FastLED.show();
}
[/color]
Code for the capacitive sensor:
#define ctsPin 2
int ledPin = 13;
void setup()
*{ *
- Serial.begin(9600);*
- pinMode(ledPin, OUTPUT);*
- pinMode(ctsPin, INPUT);*
- }*
- void loop()*
- {*
- int ctsValue = digitalRead(ctsPin);*
- if (ctsValue == HIGH)*
- { *
- digitalWrite(ledPin, HIGH); *
- Serial.println("TOUCHED");*
- } *
- else*
- { *
- digitalWrite(ledPin,LOW);*
- Serial.println("not touched");*
- } *
- delay(0.9); *
- }*
Individually these codes work, but i've been trying to combine them and then the led strip doesn't turn off and on anymore.
I hope anyone can help me out!