Hello,
Trying to understand and learn how to program my Trinket Pro using Arduino IDE.
This is my first post asking for some assistance.
First, I have been successful in merging two sketches that cause different pairs of leds to randomly flash at different rates.
I would like to combine this merged sketch with another that causes an led to fade-in, fade-out.
I'm sure the solution is something simple, but I believe once I see the solution; this will help me progress in my learning.
Here is my first merged sketch, this one operates how I want.
//This Sketch works for Communication Wall and Main Console Plue Freezing Tubes
//Communication Wall Random Blink Variables Leds 9, 10
//Main Console and Freezing Tubes Variables Leds 11, 12, 13
int CommLeds[2] = {8, 10};
int ConsoleLeds[3] = {11,12,13};
void setup() {
//Void Setup for Communication Wall
for (int jj; jj<sizeof(CommLeds) /sizeof(int);jj++) {
pinMode(CommLeds[jj], OUTPUT);
delay(10);
//void Setup for Main Console and Freezing Tubes
for (int kk; kk < sizeof(ConsoleLeds) / sizeof(int); kk++) {
pinMode(ConsoleLeds[kk], OUTPUT);
delay(10);
}
}
}
void loop() {
//Loop for Communication wall
digitalWrite(CommLeds[random(0, sizeof(CommLeds) / sizeof(int))], HIGH);
delay(random(500, 1000));
digitalWrite(CommLeds[random(0, sizeof(CommLeds) / sizeof(int))], LOW);
//Loop for Main Console and Freezing Tubes
digitalWrite(ConsoleLeds[random(0, sizeof(ConsoleLeds) / sizeof(int))], HIGH);
delay(random(20,200));
digitalWrite(ConsoleLeds[random(0, sizeof(ConsoleLeds) / sizeof(int))], LOW);
}
This sketch is my Fade-In/Fade-Out that I would like to merge into the sketch above.
int ledPin = 9; //LED connected to output digital pin 9
void setup() {
// Nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 1 points:
for (int fadeValue = 20; fadeValue <= 255; fadeValue += 1) {
// Sets the value (range from 0 to 255);
analogWrite(ledPin, fadeValue);
// Wait for 30 milliseconds to see the dimming effect
delay(20);
}
// Fade out from max to min in increments of 5 points;
for (int fadeValue = 255; fadeValue >= 20; fadeValue -= 1){
// Sets the value (range from 0 to 255);
analogWrite(ledPin, fadeValue);
// Wait for 30 milliseconds to see the dimming effect
delay(20);
}
}
Appreciate any assistance,