Cyclop’s Eye

Just like the last time, I saw another tutorial on pyroelectro. This one created a cyclop’s eye. I was interested in trying this out using my arduino. Again, it slightly departs from the tutorial. You can take a look at the code on github. I will inline the code here for a quick view. Leave your suggestions in comments!

int intensity0[] = {1, 5, 10, 100, 250};
int intensity1[] = {5, 10, 100, 250, 100};
int intensity2[] = {10, 100, 250, 100, 10};
int intensity3[] = {100, 250, 100, 10, 5};
int intensity4[] = {250, 100, 10, 5, 1};
int counter;
int up;

void setup() {
  
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  counter = 0;
  up = 1;
}

void loop() {
  analogWrite(5, intensity0[counter]);
  analogWrite(6, intensity1[counter]);
  analogWrite(9, intensity2[counter]);
  analogWrite(10, intensity3[counter]);
  analogWrite(11, intensity4[counter]);
  
  delay(200);
  if(counter == 0) up = 1;
  if(counter == 4) up = 0;
  if(up)
    counter ++;
  else 
    counter --;
}

Cloud

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.