top of page
Magic Mandala Code

int potentiometerPin=2;  //assign the potentiometer knob to analog pin 0
int ledPin=8;  //assign the LED signal to pin 8
int minDelay=2; 
 //minimum amount of delay in milliseconds between blinks (fastest blink/brightest light)
int maxDelay=26;  //maximum amount of delay in milliseconds between blinks (slowest blink/dimmest)
int onTime=500;  //time the light stays on in milliseconds, remains constant  
int potPosition;   
//analog value from the potentiometer
int strobeDelay;   //mapped value of the pot (0-1023) and the time the light remains off ranging between minDelay and maxDelay (in milliseconds)

void setup()   
{
  pinMode(ledPin,OUTPUT);
//set ledPin to give a signal
}

void loop()   
{
  potPosition = analogRead(potentiometerPin);
//read the value returning from potentiometerPin
  strobeDelay = map(potPosition, 0, 1023, minDelay, maxDelay);  //map the value from potentiometerPin between midDelay and maxDelay
  digitalWrite(ledPin,HIGH);  //Turn the LED on
  delayMicroseconds(onTime);  //Leave the LED on for 500 microseconds (500 millionths of a second or half a millisecond) 
  digitalWrite(ledPin,LOW);   //Turn the LED off
  delay(strobeDelay); //Leave the LED off for the amount that was assigned from the mapping of the potentiometer to the minDelay and maxDelay
}

Igniting Innovation through Functional Prototyping and Physical Computing

Contact Information

odysseyboardedu.@gmail.com
Phone: (360) 303-5526
24338 Lee Road
Mount Vernon, WA 98274

Contact Us

Thanks for submitting!

© 2017 by Odyssey Board. All rights reserved.

bottom of page