Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Pin
- {
- public:
- int pinNr;
- int brightness;
- int cooldown;
- bool increase = false;
- Pin(int nr){
- pinNr = nr;
- brightness = 0;
- cooldown = random(100,1000); // ändra för cooldownen första gåongen (mellan 1-75 atm)
- pinMode(nr, OUTPUT);
- }
- Pin(){
- pinNr = 0;
- brightness = 0;
- cooldown = 0;
- increase = false;
- }
- void CheckTime() // check every loop
- {
- if (increase == true){
- if (brightness >= 100)
- {
- increase = false;
- }
- else
- {
- brightness = brightness +2;
- }
- }
- else if (increase == false)
- {
- if (brightness <= 0)
- {
- if (cooldown <= 0)
- {
- increase = true;
- cooldown = random(100,1000);
- }
- else {
- cooldown = cooldown -1;
- }
- }
- else{
- brightness = brightness -2;
- }
- }
- analogWrite(pinNr, brightness);
- }
- };
- Pin pinArray[] = {Pin(3),Pin(5),Pin(6),Pin(9),Pin(10),Pin(11)};
- void setup() {
- digitalWrite(13, HIGH);
- }
- void loop() {
- for (int i = 0; i < 6; i++) {
- pinArray[i].CheckTime();
- }
- delay(30);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement