Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <IRremote.h>
- //int RECV_PIN = 4;
- //IRrecv irrecv(RECV_PIN);
- //decode_results results;
- //rgb led
- int redPin = 12;
- int greenPin = 8;
- int bluePin = 7;
- //motor pot
- int const potenciometro = 0;
- int const transTIP120 = 10;
- int valPotenciometro = 0;
- //leds
- int led = 11;
- int brightness = 0;
- int fadeAmount = 5;
- //------------------------------
- void setup()
- {
- Serial.begin(9600);
- //pot motor
- pinMode(transTIP120, OUTPUT);
- // irrecv.enableIRIn();
- //leds
- pinMode(led, OUTPUT);
- //pinMode(11, OUTPUT);
- //rgb
- pinMode(redPin, OUTPUT);
- pinMode(greenPin, OUTPUT);
- pinMode(bluePin, OUTPUT);
- //RELAY
- pinMode(2, OUTPUT);
- pinMode(3, OUTPUT);
- pinMode(5, OUTPUT);
- pinMode(6, OUTPUT);
- }
- int i1 = 0;
- int i2 = 0;
- int i3 = 0;
- int i4 = 0;
- int i5 = 0;
- int i6 = 0;
- int i7 = 0;
- int i8 = 0;
- int i9 = 0;
- //-------------------------
- void loop()
- {
- fade();
- /* if (irrecv.decode(&results))
- {
- //button 1
- if (results.value == 0xFF6897) // Red Button
- {
- setColor(255, 0, 0); // Sets Red Color to the RGB LED
- delay(100);
- }
- //button 2
- if (results.value == 0xFF9867) // Yellow Button
- {
- setColor(255, 255, 0); // Yellow Color
- delay(100);
- }
- //button OK
- if (results.value == 0xFF02FD) // Stop Button
- {
- setColor(0, 0, 0); // OFF
- delay(100);
- }
- //button 3
- if (i1 == 0 && results.value == 0xFFB04F)
- {
- digitalWrite(6, HIGH);
- i1 = 1;
- }
- else if (i1 == 1 && results.value == 0xFFB04F)
- {
- digitalWrite(6, LOW);
- i1 = 0;
- }
- //button 4
- else if (i2 == 0 && results.value == 0xFF30CF)
- {
- digitalWrite(5, HIGH);
- i2 = 1;
- }
- else if (i2 == 1 && results.value == 0xFF30CF)
- {
- digitalWrite(5, LOW);
- i2 = 0;
- }
- //button 5
- else if (i3 == 0 && results.value == 0xFF18E7)
- {
- digitalWrite(3, HIGH);
- i3 = 1;
- }
- else if (i3 == 1 && results.value == 0xFF18E7)
- {
- digitalWrite(3, LOW);
- i3 = 0;
- }
- //button 6
- else if (i4 == 0 && results.value == 0xFF7A85)
- {
- digitalWrite(2, HIGH);
- i4 = 1;
- }
- else if (i4 == 1 && results.value == 0xFF7A85)
- {
- digitalWrite(2, LOW);
- i4 = 0;
- }
- //button 7
- else if (i5 == 0 && results.value == 0xFF10EF)
- {
- digitalWrite(10, HIGH);
- i5 = 1;
- }
- else if (i5 == 1 && results.value == 0xFF10EF)
- {
- digitalWrite(10, LOW);
- i5 = 0;
- }
- //button 8
- else if (i6 == 0 && results.value == 0xFF38C7)
- {
- digitalWrite(9, HIGH);
- i6 = 1;
- fade();
- }
- else if (i6 == 1 && results.value == 0xFF38C7)
- {
- digitalWrite(9, LOW);
- i6 = 0;
- }
- irrecv.resume();
- }
- delay(100);*/
- }
- //-------------------------------------
- //rgb led
- void setColor(int red, int green, int blue)
- {
- analogWrite(redPin, red);
- analogWrite(greenPin, green);
- analogWrite(bluePin, blue);
- //potmotor
- valPotenciometro = analogRead(potenciometro) / 4;
- analogWrite(transTIP120, valPotenciometro);
- }
- //-------------------------
- void fade()
- {
- //fade led
- Serial.println(brightness);
- analogWrite(led, brightness);
- brightness = brightness + fadeAmount;
- if (brightness == 0 || brightness == 255)
- {
- fadeAmount = -fadeAmount ;
- }
- delay(30);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement