Published © CC BY-NC

Clickety-Clack The Confusing Contraption

A devious device with a single purpose, confusing whoever looks at it!

BeginnerFull instructions provided5 hours563
Clickety-Clack The Confusing Contraption

Things used in this project

Hardware components

Adafruit Feather (nRF52 Bluefruit LE - nRF52832)
×1
8 channel relay board
×1
Lipo battery 3.7V
×1
Bell Jar
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×10

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code

C/C++
int myPins[] = {2,3,4,5,28,29,13,12};
int arraySize = sizeof(myPins) / sizeof(myPins[8]);

void turnOnOne(){
  
   int pin = myPins[random(7)];
   digitalWrite(pin, HIGH);
   delay(random(500));
   digitalWrite(pin, LOW);
   delay(random(500));
  
};

void flasshAll(){
  
  for (int i=0; i< arraySize; i++) {
    digitalWrite(myPins[i], HIGH);
  }
  
  delay(random(500));
  
  for (int i=0; i< arraySize; i++) {
    digitalWrite(myPins[i], LOW);
  }
}

void rowFlashForward(){
  
  for (int i=0; i< random(10); i++) {
    digitalWrite(myPins[i], HIGH);
    delay(random(200));
    digitalWrite(myPins[i], LOW);
  }
  
}

void rowFlashBackward(){
  
  for (int i=random(10); i> 0; i--) {
    digitalWrite(myPins[i], HIGH);
    delay(random(200));
    digitalWrite(myPins[i], LOW);
  }
  
}

void setup() {
  
  Serial.begin(9600);
  for (int i=0; i< arraySize; i++) {
     pinMode(myPins[i], OUTPUT);
     digitalWrite(myPins[i], LOW);
  }
}
 
void loop() {
  
  int randNumber = random(5);
  Serial.println(randNumber);

  if(randNumber == 0){
    turnOnOne();
  }else if(randNumber == 1){
    flasshAll();
  }else if(randNumber == 2){
    rowFlashForward();
  }else if(randNumber == 3){
    rowFlashBackward();
  }else if(randNumber == 4){
    turnOnOne();
  }
}

Credits

Comments