Devices & Components
Arduino Nano
LE 16.4ft 300 SMD 5050 LEDS Flexible Strip LIghts
RFP30N06LE 30A 60V N-channel Mosfet TO-220
Generic Reed Switch
10k Ohms Potentiometer
Resistor 1k ohm
10k Ohms Potentiometer
Hardware & Tools
Soldering iron (generic)
Hot glue gun (generic)
Software & Tools
Arduino IDE
Project description
Code
Cellar Control
arduino
Controls the lighting.
1#define lights 9 //connects to gate of mosfet 2#define reed 5 3int pot = A0; 4 5void setup() { 6 Serial.begin(9600); 7 pinMode(lights, OUTPUT); 8 pinMode(reed, INPUT_PULLUP); 9} 10 11void loop() { 12 13 14 delay(200); 15 int control = analogRead(pot); 16 control = map(control, 0, 1023, 0, 255); 17 Serial.println(control); 18 delay(200); 19 //analogWrite(lights, control); 20 21 int trig = digitalRead(reed); 22 if(trig == LOW && control <= 15){ 23 Serial.println("door open"); 24 analogWrite(lights, 255); 25 delay(5000); 26 analogWrite(lights, 0); 27 delay(25000); 28 } 29 30 if(trig == LOW && control >= 15){ 31 Serial.println("door open but using"); 32 analogWrite(lights, control); 33 } 34 35 if(trig == HIGH && control >= 30){ 36 Serial.print("closed but inside"); 37 analogWrite(lights, control); 38 } 39 40 if(trig == HIGH && control <= 10){ 41 Serial.print("closed shut off lights"); 42 analogWrite(lights, 0); 43 } 44} 45
Downloadable files
Arduino Cellar Schematic
Arduino Cellar Schematic
Arduino Cellar Schematic
Arduino Cellar Schematic
Documentation
Cellar Arduino Schematic
Cellar Arduino Schematic
Cellar Arduino Schematic
Cellar Arduino Schematic
Comments
Only logged in users can leave comments